Reputation: 555
I have multiple keys in redis such as key_1, key_2, key_3 and so on. I wanted to append "s" after each keys prefix, (here key prefix is "key") so it will become keys_1, keys_2, keys_3
I am using django cache
from django.core.cache import cache
is there any functionality that can rename keys based on pattern or is there anything in redis-cli to solve this problem.
Please help.
Upvotes: 0
Views: 622
Reputation: 133
You'll need to use redis commands. Depending on the package you're using to expose redis as a cache backend, you should be able to access the redis client.
Also, if you have a lot of keys, I suggest that you iterate through the keys using the scan command instead of KEYS to avoid blocking the redis server for a long time.
Scan: https://redis.io/commands/scan
Rename key: https://redis.io/commands/rename
Upvotes: 0