redis-py icon indicating copy to clipboard operation
redis-py copied to clipboard

Question: Recreate lock from redis using its name or redis key

Open ar4hc opened this issue 2 years ago • 0 comments

Can i (re)create a Lock object from the contents of the redis DB only using the resource name or redis key?

Background: I'm now using Aioredlock for locking a resource from a REST API. One http call locks the resource, another call unlocks it, as a write lock. The parameter to the unlock is only the locks name, an the rest api is running on multiple web servers behind a load balancer.

So i don't have the original Lock object when the unlock happens. How can i unlock the lock if i only have the redis key or lock name?

Without copy/paste the do_release() method into my own code...

i'm loosing some of the original parameters of the original lock, but i can live with that. The remaining TTL is available from redis, and that's the important one.

PS: redis-py is version 4.3.4, target platform is Linux, dev on mac.

ar4hc avatar Aug 08 '22 09:08 ar4hc