trying to make redis expire more backwards compatible as each beamline has different version of redis
This commit is contained in:
+11
-1
@@ -342,8 +342,18 @@ class BeamlineConfig:
|
||||
raise Exception(
|
||||
"There is no active session with given id. Try again later."
|
||||
)
|
||||
# if active == session:
|
||||
# self.__client.expire(f"{self.__bl}:active_session", expiry_sec, gt=True)
|
||||
|
||||
if active == session:
|
||||
self.__client.expire(f"{self.__bl}:active_session", expiry_sec, gt=True)
|
||||
key = f"{self.__bl}:active_session"
|
||||
current_ttl = self.__client.ttl(key)
|
||||
|
||||
# Redis compatibility:
|
||||
# some Redis servers do not support EXPIRE with GT option.
|
||||
# Emulate "extend only if greater" manually while holding the lock.
|
||||
if current_ttl is None or current_ttl < 0 or current_ttl < expiry_sec:
|
||||
self.__client.expire(key, expiry_sec)
|
||||
else:
|
||||
raise Exception(
|
||||
"There is already active session with different id. Try again later."
|
||||
|
||||
Reference in New Issue
Block a user