Open Mogost opened 1 year ago
You could subclass and do something like:
class PrefixedLock(Lock):
def __init__(self, redis_client, prefix, name, **kwargs):
super().__init__(redis_client, name, **kwargs)
self._name = f'{prefix}:lock:{name}'
self._signal = f'{prefix}:lock-signal:{name}'
Yep. But it looks like a dirty solution. For example in this case I also need to fix this part https://github.com/ionelmc/python-redis-lock/blob/149701266b4d147d6321875f19f604e9bacf4f4f/src/redis_lock/__init__.py#L52 And it all looks like I want to hack python-redis-lock
Perhaps a key template argument could be added through all the clases/functions. Eg:
Lock(key_template={'lock': 'lock:{}', 'signal': 'lock-signal:{}'})
reset_all(key_template={'lock': 'lock:{}', 'signal': 'lock-signal:{}'})
But I do want to switch to redis functions (redis>=7) for the next release if I get to do one, so there's that...
Hi. Faced with something similar to #10
I have shared Redis cache, and control access with ACL. To separate instances I use prefixes but python-redis-lock overwrites my prefix with
lock:
https://github.com/ionelmc/python-redis-lock/blob/149701266b4d147d6321875f19f604e9bacf4f4f/src/redis_lock/__init__.py#L162 So I get an access error:Could we have a customizable prefix for this case?