Changeset - 3e5476843a19
[Not reviewed]
default
0 1 0
Mads Kiilerich - 11 years ago 2015-01-06 00:54:36
madski@unity3d.com
cache invalidation: don't commit session if nothing changed

It seems like a good idea to avoid unnecessary commits, considering we use
expire_on_commit=True.

It would perhaps be even better to postpone the commit to the end of the
session - that is for another day.
1 file changed with 3 insertions and 2 deletions:
0 comments (0 inline, 0 general)
kallithea/model/db.py
Show inline comments
 
@@ -2129,11 +2129,12 @@ class CacheInvalidation(Base, BaseModel)
 
            inv_obj = cls.query().filter(cls.cache_key == cache_key).scalar()
 
            if not inv_obj:
 
                inv_obj = CacheInvalidation(cache_key, repo_name)
 
            was_valid = inv_obj.cache_active
 
            if inv_obj.cache_active:
 
                return True
 
            inv_obj.cache_active = True
 
            Session().add(inv_obj)
 
            Session().commit()
 
            return was_valid
 
            return False
 
        except Exception:
 
            log.error(traceback.format_exc())
 
            Session().rollback()
0 comments (0 inline, 0 general)