You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How can I choose which Redis DB number is used by node-redlock?
I have a perfectly good redis instance I'd like to use for redlock, but I don't want to pollute the data in DB #0 and I'd like to configure node-redlock to use another DB. Is this possible?
The text was updated successfully, but these errors were encountered:
For anyone else curious about the same functionality, at this point I am manually selecting the DB # on my ioredis Redis client instance prior to calling using() on my redlock instance which uses the Redis instance:
My only remaining concern is that I intended to share the Redis client instance as a singleton across my application, and there's a non-zero chance for a race condition where another call to the same Redis client could set the DB to something other than 8 prior to the using() executing.
In the meantime, I have initialized another bespoke instance of the Redis client specifically for use with the redlock instance.
I would like to see a configurable dbNumber value in node-redlock which accepts the DB # and utilizes it in the Lua scripts directly to ensure no susceptibility to race conditions on the same Redis client instance. If dbNumber is not provided then it should default to 0 for backwards compatibility and to ensure support for services such as AWS Serverless Elasticache, which only support 1 Redis DB (DB 0).
rbonestell
changed the title
Choose which Redis DB # is used?
Configure Redis DB # explicitly?
Jun 5, 2024
How can I choose which Redis DB number is used by node-redlock?
I have a perfectly good redis instance I'd like to use for redlock, but I don't want to pollute the data in DB #0 and I'd like to configure node-redlock to use another DB. Is this possible?
The text was updated successfully, but these errors were encountered: