Normally, I get the key set then use a look to delete each key/value pair.
Is it possible to just delete all keys via pattern?
ie:
Del sample_pattern:*
Normally, I get the key set then use a look to delete each key/value pair.
Is it possible to just delete all keys via pattern?
ie:
Del sample_pattern:*
You can do it with bash:
KEYS is not recommended to use due to its inefficiencies when used in production. Please see https://redis.io/commands/keys. Instead, it is better to use SCAN. Additionally, a more efficient call than repeated calls to jedis.del() is to make one single call to jedis to remove the matching keys, passing in an array of keys to delete. A more efficient solution is presented below:
You can do it with the Redisson in one line:
It seems, for Jedis, to "delete by pattern" is basically getting all the keys of a specific pattern then loop through it.
ie
You should try using eval. I'm no Lua expert, but this code works.
And then call:
This guarantees a one server-side call, multiple delete operation.
Using java to delete, it's seem like this: