Mercurial > kallithea
changeset 4743:3e5476843a19
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.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Tue, 06 Jan 2015 00:54:36 +0100 |
parents | ded49765b47a |
children | 6678b977f859 |
files | kallithea/model/db.py |
diffstat | 1 files changed, 3 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/model/db.py Tue Jan 06 00:54:36 2015 +0100 +++ b/kallithea/model/db.py Tue Jan 06 00:54:36 2015 +0100 @@ -2129,11 +2129,12 @@ 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()