Skip to Content
  • +31 653-919-302
Cafayate.Net
  • 0
  • 0
  • Sign in
  • Nederlands English (US) Español (AR)
  • Contact Us
  • Home
  • Blog
  • Jobs
  • Contact us
Cafayate.Net
  • 0
  • 0
    • Home
    • Blog
    • Jobs
    • Contact us
  • +31 653-919-302
  • Nederlands English (US) Español (AR)
  • Sign in
  • Contact Us

Deleting lots of keys in Redis, fast

  • All Blogs
  • Tech Blog
  • Deleting lots of keys in Redis, fast
  • March 5, 2021 by
    Administrator

     

    Here’s a snippet that has helped me whenever I’ve wanted to delete a large number of keys in Redis. This snippet can be run from a bash (or equivalent) shell. In this example i want to delete all keys that begin with ‘sessions’.


    redis-cli KEYS "sessions*" | xargs --max-args=100 --max-procs=8 redis-cli DEL

    The first part of the script runs the KEYS command searching for keys that begin with ‘sessions’. (NOTE: It’s obviously useless to delete ALL keys this way. You might as well delete the .rdb or .aof file and restart the server.)

    The second part runs the DEL command with a 100 arguments at a time. `–max-procs=8` means there are 8 processes running in parallel. Adjust –max-procs per the number of cores on your server.

    in Tech Blog
    Odoo Website Portal (Backported From v10)

    Designed for companies

    We are a team of passionate people whose goal is to improve everyone's life through disruptive products. We build great products to solve your business problems. Our products are designed for small to medium size companies willing to optimize their performance.

    Get in touch

    Plantexel
    Pedernera
    Salta Capital 
    Argenina

    • +31 653-919-302
    • [email protected]
    Follow us
    Copyright © Plantexel
    Nederlands | English (US) | Español (AR)