summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Kopaczewski <rk@23doors.com>2014-12-11 06:53:42 +0100
committerRobert Kopaczewski <rk@23doors.com>2014-12-11 06:53:42 +0100
commitbb422881ffedf51710f96b29614f030ea71327f3 (patch)
treeafdd5a8346801b904f2f6ecc583963392e0c85e6
parent08d37bd490014ebbba9f6c60e1f149e7255b69b4 (diff)
downloadredis-py-bb422881ffedf51710f96b29614f030ea71327f3.tar.gz
Removing do_acquire from lualock as there is no gain over default do_acquire
-rw-r--r--redis/lock.py24
1 files changed, 0 insertions, 24 deletions
diff --git a/redis/lock.py b/redis/lock.py
index fc94ed5..732568b 100644
--- a/redis/lock.py
+++ b/redis/lock.py
@@ -189,26 +189,10 @@ class LuaLock(Lock):
A lock implementation that uses Lua scripts rather than pipelines
and watches.
"""
- lua_acquire = None
lua_release = None
lua_extend = None
# KEYS[1] - lock name
- # ARGV[1] - token
- # ARGV[2] - timeout in milliseconds
- # return 1 if lock was acquired, otherwise 0
- LUA_ACQUIRE_SCRIPT = """
- local args = {}
- if ARGV[2] ~= '' then
- args = {'px', ARGV[2]}
- end
- if redis.call('set', KEYS[1], ARGV[1], 'nx', unpack(args)) then
- return 1
- end
- return 0
- """
-
- # KEYS[1] - lock name
# ARGS[1] - token
# return 1 if the lock was released, otherwise 0
LUA_RELEASE_SCRIPT = """
@@ -246,19 +230,11 @@ class LuaLock(Lock):
@classmethod
def register_scripts(cls, redis):
- if cls.lua_acquire is None:
- cls.lua_acquire = redis.register_script(cls.LUA_ACQUIRE_SCRIPT)
if cls.lua_release is None:
cls.lua_release = redis.register_script(cls.LUA_RELEASE_SCRIPT)
if cls.lua_extend is None:
cls.lua_extend = redis.register_script(cls.LUA_EXTEND_SCRIPT)
- def do_acquire(self, token):
- timeout = self.timeout and int(self.timeout * 1000) or ''
- return bool(self.lua_acquire(keys=[self.name],
- args=[token, timeout],
- client=self.redis))
-
def do_release(self, expected_token):
if not bool(self.lua_release(keys=[self.name],
args=[expected_token],