logo
Tags down

shadow

How to delete keys matching a pattern in Redis Cluster


By : jack
Date : October 17 2020, 08:10 PM
this will help Answers for that question try to remove multiple keys in a single DEL. However, keys matching the given pattern might NOT locate in the same slot, and Redis Cluster DOES NOT support multiple-key command if these keys don't belong to the same slot. That's why you get the error message.
In order to fix this problem, you need to DEL these keys one-by-one:
code :
redis-cli --scan --pattern "foo*" |xargs -L 1 redis-cli del


Share : facebook icon twitter icon

How to atomically delete keys matching a pattern using Redis


By : Ed van Hengel
Date : March 29 2020, 07:55 AM
To fix the issue you can do Starting with redis 2.6.0, you can run lua scripts, which execute atomically. I have never written one, but I think it would look something like this
code :
EVAL "return redis.call('del', unpack(redis.call('keys', ARGV[1])))" 0 prefix:[YOUR_PREFIX e.g delete_me_*]

Using the redis ruby gem, how do I clear a set of keys from redis matching a pattern?


By : Samer Kadib Alban
Date : March 29 2020, 07:55 AM
This might help you I'm using Redis with Ruby on Rails. , AFAIK client.del "some_key" will try to erase somekey*

How to delete keys matching a certain pattern in redis


By : user3196443
Date : March 29 2020, 07:55 AM
Any of those help As mentioned in the comment on the question, there are many other answers to this here already. Definitely read the one linked above if you are thinking about doing this in a production sever.
The one I found most useful for occasional command-line cleanup was:

Redis: how to delete multiple keys matching pattern?


By : user3852365
Date : March 29 2020, 07:55 AM
it should still fix some issue Whether you DEL or EXPIRE, once Lua script runs it will block other clients and if it runs for too long it the lua-time-limit timeout. Despite your reluctance for looping, I strongly recommend you do.
Expiry vs deletion may lessen some of the immediate load (yet to be empirically proven), so feel free to go with one or the other. In either case, use a client-side loop on a SCAN operation to invoke the command for each key. If you have a server/worker process somewhere in your architecture, you can consider delegating this task to it so the client will not be kept busy.

Delete Redis Keys matching a pattern Laravel 5.7


By : user3319165
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , You can't delete by pattern. But you can get all the keys by this pattern and then delete them:
code :
Redis::del(Redis::keys('products:*'));
Related Posts Related Posts :
shadow
Privacy Policy - Terms - Contact Us © voile276.org