Show More
@@ -1669,19 +1669,6 b' class CacheInvalidation(Base, BaseModel)' | |||
|
1669 | 1669 | return "%s%s" % (prefix, key) |
|
1670 | 1670 | |
|
1671 | 1671 | @classmethod |
|
1672 | def _get_or_create_inv_obj(cls, key, repo_name): | |
|
1673 | inv_obj = Session().query(cls).filter(cls.cache_key == key).scalar() | |
|
1674 | if not inv_obj: | |
|
1675 | try: | |
|
1676 | inv_obj = CacheInvalidation(key, repo_name) | |
|
1677 | Session().add(inv_obj) | |
|
1678 | Session().commit() | |
|
1679 | except Exception: | |
|
1680 | log.error(traceback.format_exc()) | |
|
1681 | Session().rollback() | |
|
1682 | return inv_obj | |
|
1683 | ||
|
1684 | @classmethod | |
|
1685 | 1672 | def invalidate(cls, key): |
|
1686 | 1673 | """ |
|
1687 | 1674 | Returns Invalidation object if the local cache with the given key is invalid, |
@@ -1693,9 +1680,18 b' class CacheInvalidation(Base, BaseModel)' | |||
|
1693 | 1680 | repo_name = remove_suffix(repo_name, '_ATOM') |
|
1694 | 1681 | |
|
1695 | 1682 | cache_key = cls._get_cache_key(key) |
|
1696 | inv_obj = cls._get_or_create_inv_obj(cache_key, repo_name) | |
|
1683 | inv_obj = Session().query(cls).filter(cls.cache_key == cache_key).scalar() | |
|
1684 | if not inv_obj: | |
|
1685 | try: | |
|
1686 | inv_obj = CacheInvalidation(cache_key, repo_name) | |
|
1687 | Session().add(inv_obj) | |
|
1688 | Session().commit() | |
|
1689 | except Exception: | |
|
1690 | log.error(traceback.format_exc()) | |
|
1691 | Session().rollback() | |
|
1692 | return | |
|
1697 | 1693 | |
|
1698 |
if |
|
|
1694 | if not inv_obj.cache_active: | |
|
1699 | 1695 | # `cache_active = False` means that this cache |
|
1700 | 1696 | # no longer is valid |
|
1701 | 1697 | return inv_obj |
General Comments 0
You need to be logged in to leave comments.
Login now