(create {:keys [lock-key lock-id expiry-ms acquire-timeout-ms
acquire-resolution-ms release-on-stop?]
:or {release-on-stop? true
expiry-ms default-expiry-ms
acquire-timeout-ms default-acquire-timeout-ms
acquire-resolution-ms default-acquire-resolution-ms}})(create-mock {:keys [always-acquire?] :or {always-acquire? true}})Creates a mock RedLock implementation for testing purposes. Options:
:always-acquire? - if true, acquire and acquire-with-timeout will always succeed (default: true)Creates a mock RedLock implementation for testing purposes. Options: - `:always-acquire?` - if true, `acquire` and `acquire-with-timeout` will always succeed (default: true)
(acquire this)(acquire this opts)Acquire the lock. Returns true if acquired, false otherwise. If this instance already holds the lock, acquiring again succeeds and refreshes the expiry.
Acquire the lock. Returns true if acquired, false otherwise. If this instance already holds the lock, acquiring again succeeds and refreshes the expiry.
(acquire-with-timeout this)(acquire-with-timeout this opts)Like acquire but will wait for the lock to be available up to acquire-timeout-ms milliseconds.
If the lock is not acquired within that time, returns false.
Like `acquire` but will wait for the lock to be available up to `acquire-timeout-ms` milliseconds. If the lock is not acquired within that time, returns false.
(get-id this)Returns the lock ID of this instance, regardless of whether it holds the lock.
Returns the lock ID of this instance, regardless of whether it holds the lock.
(get-lock-holder-id this)Returns the lock ID of the current lock holder, nil if the lock is not held.
Returns the lock ID of the current lock holder, nil if the lock is not held.
(is-lock-holder? this)Check if this instance is the lock holder. Returns true if it is, false otherwise.
Check if this instance is the lock holder. Returns true if it is, false otherwise.
(lock-expiry-in-ms this)Returns number of milliseconds until the lock expires.
If the lock doesn't exist, the result is negative - don't rely on it to check if the lock is held, use is-lock-holder? instead.
Returns number of milliseconds until the lock expires. If the lock doesn't exist, the result is negative - don't rely on it to check if the lock is held, use `is-lock-holder?` instead.
(release this)Release the lock. Always returns true, even if this instance was not the lock holder.
Release the lock. Always returns true, even if this instance was not the lock holder.
(renew this)Renew the lock. Returns true if renewed, false otherwise.
Renew the lock. Returns true if renewed, false otherwise.
(try-acquire* conn {:keys [lock-key lock-id expiry-ms]})Try acquiring a lock, doesn't use timeouts - so it either acquires the lock or fails immediately. Returns true if acquired, false otherwise.
Try acquiring a lock, doesn't use timeouts - so it either acquires the lock or fails immediately. Returns true if acquired, false otherwise.
(try-acquire-with-timeout* conn
{:keys [lock-key lock-id expiry-ms acquire-timeout-ms
acquire-resolution-ms]})Try acquiring a lock, with a timeout options
Try acquiring a lock, with a timeout options
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |