mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 11:11:13 +08:00
DEV: correct implementation of expiry api
Previously we were always hard-coding expiry, this allows the secure session to correctly handle custom expiry times Also adds a ttl method for looking up time to live
This commit is contained in:
@ -16,10 +16,14 @@ class SecureSession
|
||||
|
||||
def set(key, val, expires: nil)
|
||||
expires ||= SecureSession.expiry
|
||||
$redis.setex(prefixed_key(key), SecureSession.expiry.to_i, val.to_s)
|
||||
$redis.setex(prefixed_key(key), expires.to_i, val.to_s)
|
||||
true
|
||||
end
|
||||
|
||||
def ttl(key)
|
||||
$redis.ttl(prefixed_key(key))
|
||||
end
|
||||
|
||||
def [](key)
|
||||
$redis.get(prefixed_key(key))
|
||||
end
|
||||
|
Reference in New Issue
Block a user