trying to make redis expire more backwards compatible as each beamline has different version of redis

This commit is contained in:
2026-06-24 15:29:59 +02:00
committed by appleb_m
parent 350068378b
commit 18bd5bc87a
+11 -1
View File
@@ -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."