I need to use NodeJS to delete all records in Redis that match a prefix / wildcard. I'm using this package: https://github.com/NodeRedis/node_redis
I have seen several solutions available to delete Redis keys that feature a prefix and a wildcard e.g.
KEYS "web.*"
However, all of these solutions rely on using the KEYS
command which is not suitable for production due to it locking up the server. I believe the correct solution involves the SCAN
command (and perhaps others), but I don't fully understand how it works.
I'm looking for a simple JS function that allows me to pass in a string containing the prefix and wildcard e.g. "web.*" and all "keys" matching keys will be deleted.
Many thanks!