Packages
charon
4.0.0-beta3
4.3.0
4.3.0-beta1
4.2.0
4.2.0-beta3
4.2.0-beta2
4.2.0-beta1
4.1.0
4.0.1
4.0.0
4.0.0-beta3
4.0.0-beta2
4.0.0-beta1
3.4.1
3.4.0
3.3.0
3.2.0
3.1.1
3.1.0
3.0.3
3.0.2
3.0.1
3.0.0
3.0.0-beta1
2.8.0
2.8.0-beta1
2.7.3
2.7.2
2.7.1
2.7.0
2.6.1
2.6.0
2.5.0
2.4.0
2.3.0
2.2.0
2.2.0-beta
2.1.3
2.1.2
2.1.2-beta
2.1.1
2.1.0
2.0.0
1.3.4
1.3.3
1.3.2-beta
1.3.1-beta
1.3.0-beta
1.2.0-beta
1.1.0-beta
1.0.1-beta
1.0.0-beta1
0.0.4-alpha
0.0.3-alpha
0.0.2-alpha
0.0.1-alpha
Authentication & sessions for API's.
Current section
Files
Jump to
Current section
Files
priv/redis_functions.lua
#!lua name=charon_redis_store_0.0.0+development
------------
-- PUBLIC --
------------
local function opt_lock_upsert(keys, args)
local session_set_key = unpack(keys)
local sid, lock_key, lock_version, session, expires_at = unpack(args)
local current_lock = redis.call("HGET", session_set_key, lock_key)
-- if current_lock exists, this is an update, not an insert
if current_lock and current_lock + 1 ~= tonumber(lock_version) then
return "CONFLICT"
else
return redis.call("HSETEX", session_set_key, "EXAT", expires_at, "FIELDS", 2, sid, session, lock_key, lock_version)
end
end
redis.register_function('opt_lock_upsert_0.0.0+development', opt_lock_upsert)