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

This commit is contained in:
appleb_m committed 2026-06-15 14:14:48 +02:00
1 parent 105f52987b
commit 898fa26cdd
1 file changed
+11 -1
+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."