exception handling in sco_cache set

This commit is contained in:
Emmanuel Viennet 2021-07-26 18:11:45 +03:00
parent 0252bf4df4
commit 79e43adbc3

View File

@ -85,7 +85,7 @@ class ScoDocCache:
try: try:
return CACHE.get(cls._get_key(oid)) return CACHE.get(cls._get_key(oid))
except pylibmc.Error: except pylibmc.Error:
log("Warning: memcached error") log("Warning: memcached error in get")
log(traceback.format_exc()) log(traceback.format_exc())
return None return None
@ -94,9 +94,13 @@ class ScoDocCache:
"""Store value""" """Store value"""
key = cls._get_key(oid) key = cls._get_key(oid)
# log(f"CACHE key={key}, type={type(value)}, timeout={cls.timeout}") # log(f"CACHE key={key}, type={type(value)}, timeout={cls.timeout}")
try:
status = CACHE.set(key, value, timeout=cls.timeout) status = CACHE.set(key, value, timeout=cls.timeout)
if not status: if not status:
log("Error: cache set failed !") log("Error: cache set failed !")
except pylibmc.Error:
log("Warning: memcached error in set")
return status return status
@classmethod @classmethod