79291467

Date: 2024-12-18 14:41:09
Score: 1
Natty:
Report link

Unfortunately, Redis does not provide a native “negative match” pattern or a built-in command to flush all keys except for a specific one. You must instead retrieve all keys and then filter them out before deleting.

Approach using a shell pipeline: 1. List all keys with redis-cli keys "*". 2. Use grep -v to exclude the key zrtt_industry. 3. Pass the remaining keys to redis-cli del via xargs.

For example:

redis-cli -h zapi.data.com KEYS "*" | grep -v '^zrtt_industry$' | xargs -n 1 redis-cli -h zapi.data.com DEL

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Akhil Singh