@@ -2133,25 +2133,31 @@ class CacheInvalidation(Base, BaseModel)
cache_key = cls._get_cache_key(key)
if valid_cache_keys and cache_key in valid_cache_keys:
return True
inv_obj = cls.query().filter(cls.cache_key == cache_key).scalar()
if not inv_obj:
inv_obj = CacheInvalidation(cache_key, repo_name)
if inv_obj.cache_active:
inv_obj.cache_active = True
Session().add(inv_obj)
try:
Session().commit()
except exc.IntegrityError:
raise
# TOCTOU - another thread added the key at the same time; no further action required
return False
@classmethod
def get_valid_cache_keys(cls):
"""
Return opaque object with information of which caches still are valid
and can be used without checking for invalidation.
return set(inv_obj.cache_key for inv_obj in cls.query().filter(cls.cache_active).all())
class ChangesetComment(Base, BaseModel):
Status change: