Efficient way to delete keys by pattern
See original GitHub issueI’m working on a big project and in some places, I have to delete keys by a pattern, for example, I want to delete all the keys that start with filterProducts
I made a Google search and found some methods to do so like, for example, the method in this article
But I don’t know what is the efficient one for a big project, could you please help me?
- Version: 2.8.0
- Platform: Linux Mint 18.2(Built on Ubuntu 16.04)
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (2 by maintainers)
Top Results From Across the Web
Find and Delete multiple keys matching by a pattern in Redis
Use scanstream to find and pipeline to delete keys matching pattern. ... there is no way to delete all keys matching a pattern...
Read more >How to Delete Keys Matching a Pattern in Redis | RDBTools
This command will delete all keys matching users:* If you are in redis 4.0 or above, you can use the unlink command instead...
Read more >How to atomically delete keys matching a pattern using Redis
The following Bash script demonstrates deletion of keys by pattern: #!/bin/bash if [ $# -ne 3 ] then echo "Delete keys from Redis...
Read more >Ways to delete multiple keys from Redis cache. - Medium
Redis cache key can be deleted in two ways. With Keys Command. Keys command will scan all the keys present in the Redis...
Read more >Redis delete all keys with prefix - Easy way to do it - Bobcares
If we want to delete a bunch of keys that match a common prefix, we delete them by pattern. At Bobcares, we often...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For anyone that looking for the final result that we until now reached to and believe it is the most efficient way is the following:
The code above is for ioredis. Please if you are someone that knows a better way of doing so please don’t hesitate to share.
@dirkbonhomme Thank you so much for your help, I really appreciate that.
I followed your advice and used ioredis and created the following functions, could you please just tell me for big projects is the following the most efficient way for doing so or not: