Commit Graph

39 Commits

Author SHA1 Message Date
Nick Elser
6b6eb4e590 Merge pull request #15 from doits/monotonic_time
use monotonic time for retry timeout check
2021-01-21 10:27:46 -08:00
Matt Larraz
3a37a74982 Support connection pooled Redis 2021-01-20 16:47:30 -08:00
Markus Doits
6e74322ff1 use monotonic time for retry timeout check 2021-01-07 12:52:21 +01:00
Nick Elser
b9d3f1b7a1 Bump version and update changelog. 2019-09-04 14:36:40 -07:00
Lev Kokotov
9b8ef6c244 Add support for pooled memcached clients by using #with 2019-08-22 16:04:14 -07:00
Nick Elser
8ed488f071 Merge pull request #5 from keylimetoolbox/double-initial-set
Fix #initial_set which is causing a double attempt and delay on lock acquisition and incorrect drop on short acquisition_timeout
2018-10-05 13:28:16 -07:00
Nick Elser
5e10afe534 Update Rubocop, and bump the version. 2018-10-05 16:14:49 -04:00
Ian Remillard
ca46f5f369 add default for expire on set 2018-10-01 10:48:50 -07:00
Ian Remillard
1022a6f9d3 move to expire only when all locks are released 2018-10-01 10:35:30 -07:00
Ian Remillard
fdb0b7f9d5 adds lock ttl and lock_release_removes_key 2018-09-28 12:43:52 -07:00
Jeremy Wadsack
a13edcf7d1 Fix #initial_set which is causing a double attempt and delay on lock acquisition
The call to `#initial_set` in `#retry` and `#acquire_lock` is followed by `next` which leads to a second pass through the `#retry_with_timeout` loop and a sleep call for up to `:acquisition_delay`. This delay isn't necessary if the value can be set without a race condition.

Removing the `next` call causes the client to continue to retry because the transaction has been changed outside the transaction boundary:

In Redis, calling `SET` within a `WATCH`/`UNWATCH` block but not inside a `MULTI`/`EXEC` block will [cause the EXEC to fail the transaction](https://github.com/antirez/redis-doc/issues/734), so the first `#set` call fails and it requires a second pass. To resolve this I changed `#initial_set` to call `#set` within a `MULTI` block so that it would be inside the transaction.

In Memcache the call to `SET` without the `CAS` during `#initial_set` is going to cause the `SET` with `CAS` to fail (return `EXISTS`), and resulting in a second pass. To resolve this I changed `#initial_set` to use `SET` with `CAS` and return the CAS value to be used in the subsequent `#set` call that stores the lock token.
2018-08-30 13:06:16 -07:00
Nick Elser
af1c476f08 Bump version. 2016-10-06 10:22:36 -07:00
Vokhmin Alexey V
05661e143c Allow to use custom token for lock 2016-10-05 13:47:10 +03:00
Nick Elser
a23282dcc6 don't go around allocating empty strings willy-nilly 2015-05-07 00:16:28 -07:00
Nick Elser
745d49466f release v0.3.0 2015-04-15 23:11:06 -07:00
Nick Elser
81e4a3e143 dramatically simpify interface by forcing key at initialization 2015-04-15 23:10:21 -07:00
Nick Elser
aaee69a2df release v0.2.3 2015-04-13 22:15:14 -07:00
Nick Elser
498073b92e tiny code style improvements 2015-04-13 21:55:34 -07:00
Nick Elser
155a3ac40c release v0.2.2 2015-04-13 21:45:47 -07:00
Nick Elser
10d3ab09cf handle invalid lock data 2015-04-13 21:40:54 -07:00
Nick Elser
7591c08a28 avoid name collision for locks method 2015-04-13 20:29:03 -07:00
Nick Elser
49a9757d44 fix refresh token 2015-04-13 19:37:34 -07:00
Nick Elser
857fc63378 release 0.2.1 2015-04-12 23:45:09 -07:00
Nick Elser
bb6762bbc6 ret is not always an array 2015-04-12 23:45:00 -07:00
Nick Elser
f0977c89f2 remove redundant require file 2015-04-12 23:03:54 -07:00
Nick Elser
4d5c96309f some style fixes 2015-04-12 22:54:53 -07:00
Nick Elser
ce0a4d8d86 release 0.2.0 2015-04-12 22:33:19 -07:00
Nick Elser
1fd769eec2 refactor class methods into instance methods 2015-04-12 22:32:51 -07:00
Nick Elser
37be5ae27b bump version, update changelog 2015-04-12 20:58:18 -07:00
Nick Elser
8d7ddaf35a move logic around loop counts to a more reasonable location 2015-04-12 20:57:29 -07:00
Nick Elser
1aacc0c1a1 properly throw lock LockClientError 2015-04-12 20:47:35 -07:00
Nick Elser
887219b63d release 0.1.2 2015-04-12 19:43:59 -07:00
Nick Elser
c0905fef91 faster unpack without exceptions 2015-04-12 19:43:07 -07:00
Nick Elser
a54b795e20 simplify defaults logic and fix retry timeouts 2015-04-12 19:42:59 -07:00
Nick Elser
c2b9de4cf3 refactor shared logic into base class 2015-04-12 17:54:30 -07:00
Nick Elser
d8f8350d1c check timeout at the entry of the loop 2015-04-12 15:57:32 -07:00
Nick Elser
1668756a48 update changelog 2015-04-12 15:45:36 -07:00
Nick Elser
30639cae72 use msgpack for efficiency 2015-04-12 15:28:53 -07:00
Nick Elser
06d296c8d9 first commit 2015-04-12 13:40:53 -07:00