{"action":"created","issue":{"url":"https://api.github.com/repos/abelaska/jedis-lock/issues/3","labels_url":"https://api.github.com/repos/abelaska/jedis-lock/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/abelaska/jedis-lock/issues/3/comments","events_url":"https://api.github.com/repos/abelaska/jedis-lock/issues/3/events","html_url":"https://github.com/abelaska/jedis-lock/pull/3","id":46555051,"number":3,"title":"Simplify lock expiration mechanism and add ownership safety to release()","user":{"login":"tonyghita","id":779738,"avatar_url":"https://avatars.githubusercontent.com/u/779738?v=3","gravatar_id":"","url":"https://api.github.com/users/tonyghita","html_url":"https://github.com/tonyghita","followers_url":"https://api.github.com/users/tonyghita/followers","following_url":"https://api.github.com/users/tonyghita/following{/other_user}","gists_url":"https://api.github.com/users/tonyghita/gists{/gist_id}","starred_url":"https://api.github.com/users/tonyghita/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tonyghita/subscriptions","organizations_url":"https://api.github.com/users/tonyghita/orgs","repos_url":"https://api.github.com/users/tonyghita/repos","events_url":"https://api.github.com/users/tonyghita/events{/privacy}","received_events_url":"https://api.github.com/users/tonyghita/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2014-10-22T20:16:02Z","updated_at":"2016-01-12T07:53:06Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/abelaska/jedis-lock/pulls/3","html_url":"https://github.com/abelaska/jedis-lock/pull/3","diff_url":"https://github.com/abelaska/jedis-lock/pull/3.diff","patch_url":"https://github.com/abelaska/jedis-lock/pull/3.patch"},"body":"cc @abelaska \r\n\r\nReviving this project from 4 years of dormancy :) Some notes: \r\n\r\nSimplifying the lock expiration mechanism:\r\n\r\nSince Redis 2.6.12, the SET operation supports a set of options which\r\nmodify its behavior (see: http://redis.io/commands/set). The options\r\nwe are interested in are PX (set specified expire time in ms) and NX\r\n(only set the key if it does not already exist).\r\n\r\nThe ability to perform both of these atomically is awesome for our use\r\ncase. Replacing the former call to SETNX with the new SET with options\r\nnot only moves us away from using deprecated functionality but also\r\nallows us to drop the expiration checking code of past.\r\n\r\nAdding lock ownership for safety:\r\n\r\nTo prevent locks from releasing each others hold on keys, we introduce a\r\nunique token. The token is the value of the lockKey. In release(), a\r\ncheck was added which (atomically, with the Lua script) releases the\r\nlock only if the lock owner releases.\r\n\r\nUnfortunately, I don't believe there is any way to achieve this behavior\r\nwith Redis without the aid of a Lua script."},"comment":{"url":"https://api.github.com/repos/abelaska/jedis-lock/issues/comments/170830417","html_url":"https://github.com/abelaska/jedis-lock/pull/3#issuecomment-170830417","issue_url":"https://api.github.com/repos/abelaska/jedis-lock/issues/3","id":170830417,"user":{"login":"abelaska","id":177991,"avatar_url":"https://avatars.githubusercontent.com/u/177991?v=3","gravatar_id":"","url":"https://api.github.com/users/abelaska","html_url":"https://github.com/abelaska","followers_url":"https://api.github.com/users/abelaska/followers","following_url":"https://api.github.com/users/abelaska/following{/other_user}","gists_url":"https://api.github.com/users/abelaska/gists{/gist_id}","starred_url":"https://api.github.com/users/abelaska/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abelaska/subscriptions","organizations_url":"https://api.github.com/users/abelaska/orgs","repos_url":"https://api.github.com/users/abelaska/repos","events_url":"https://api.github.com/users/abelaska/events{/privacy}","received_events_url":"https://api.github.com/users/abelaska/received_events","type":"User","site_admin":false},"created_at":"2016-01-12T07:53:06Z","updated_at":"2016-01-12T07:53:06Z","body":"@tonyghita if you can prepare PR I can easily merge I'll merge it. Thanks."}}