I saw this example on removing Key from redis usign wildcard
You can delete multiple keys with just one DEL command
DEL key1 key2 key3......
You can also delete all keys matching an expression this way
redis-cli KEYS "temp_cart:user*" | xargs redis-cli DEL
Let's say i have keys : key1a, key2b,key7a, .... and i would like to remove all that starts with key*
how do i tell booksleve to do that? when i pass string into its invalidate function with "keys*" it does not seem to do the trick.
Redis does not have a "delete by wildcard" operation. Note also that you should never use
KEYS
in production. At worst you should useSCAN
. Fortunately, BookSleeve and SE.Redis automatically useSCAN
when available. To do this, you would have to iterate (viaSCAN
) and issue multilpleDEL
commands. Which is, notably, exactly whatxargs
does in your example.