Redis

Redis: bulk-deleting keys by prefix

redis-cli --scan --pattern 'KEY_PREFIX*' | xargs -r -n 500 redis-cli UNLINK

--scan walks the keys in chunks.

UNLINK — it frees the memory on a separate thread, no blocking. -n 500 so you don’t spawn a process per key, -r skips the call when nothing matches.

Check what you’re about to nuke first:

redis-cli --scan --pattern 'KEY_PREFIX*' | head

--scan only walks on your current node (check –cluster call for cluster)