class LuaScripts

Shared Redis Lua scripts for lock and limiter primitives.

Methods

static string
releaseLock()

Get the Lua script to atomically release a lock.

static string
refreshLock()

Get the Lua script to atomically refresh a lock's TTL.

static string
acquireConcurrencySlot()

Get the Lua script for atomically acquiring a free concurrency-limiter slot.

Details

at line 18
static string releaseLock()

Get the Lua script to atomically release a lock.

KEYS[1] - The name of the lock ARGV[1] - The owner key of the lock instance trying to release it

Return Value

string

at line 36
static string refreshLock()

Get the Lua script to atomically refresh a lock's TTL.

KEYS[1] - The name of the lock ARGV[1] - The owner key of the lock instance trying to refresh it ARGV[2] - The new TTL in seconds

Return Value

string

at line 63
static string acquireConcurrencySlot()

Get the Lua script for atomically acquiring a free concurrency-limiter slot.

KEYS - The prefixed slot keys to consider (one per limit) ARGV[1] - The unprefixed limiter name (used to construct the return value) ARGV[2] - The number of seconds the slot should be reserved (0 = permanent, no TTL) ARGV[3] - The unique identifier (owner) for this lock

Returns the UNPREFIXED slot name (e.g. "my-funnel1") on success, nil otherwise. The unprefixed return is required so the caller can pass it to RedisStore::restoreLock() which prepends the prefix exactly once.

For ARGV[2] <= 0 the script writes the slot key without an EX expiration, matching RedisLock::acquire()'s "seconds <= 0 means permanent" semantic. Sending EX 0 to Redis would error with "invalid expire time in 'set' command".

Return Value

string