perf: warm the cache after all transactions
This is the simplest way to ensure the data are up to date.
--- a/hgext3rd/evolve/obscache.py Mon May 01 08:13:24 2017 +0200
+++ b/hgext3rd/evolve/obscache.py Mon May 01 08:14:00 2017 +0200
@@ -318,4 +318,25 @@
if 'obsstore' in vars(self):
self.obsstore.obscache.clear()
+ def transaction(self, *args, **kwargs):
+ tr = super(obscacherepo, self).transaction(*args, **kwargs)
+ reporef = weakref.ref(self)
+
+ def _warmcache(tr):
+ repo = reporef()
+ if repo is None:
+ return
+ if 'obsstore' in vars(self):
+ repo = repo.unfiltered()
+ # As pointed in 'obscache.update', we could have the
+ # changelog and the obsstore in charge of updating the
+ # cache when new items goes it. The tranaction logic would
+ # then only be involved for the 'pending' and final saving
+ # logic.
+ self.obsstore.obscache.update(repo)
+ self.obsstore.obscache.save(repo)
+
+ tr.addpostclose('warmcache-obscache', _warmcache)
+ return tr
+
repo.__class__ = obscacherepo