Batch delete Redis keys

Deleting keys one at a time costs one round trip per key. xargs can batch them instead:

redis-cli --scan --count 1000 --pattern 'session:*' \
  | xargs -L1000 redis-cli DEL

--scan lists the matching keys one per line. xargs -L1000 packs every thousand of them into a single DEL, so 100k keys take 100 round trips instead of 100k.

    subscribe

    New entries from Event Log by email. No spam, unsubscribe any time.

    Or follow the RSS feed.