1) the set of installed packages (including COUNTER) has changed
2) the old-style virtuals have changed
"""
+
+ # Number of uncached packages to trigger cache update, since
+ # it's wasteful to update it for every vdb change.
+ _cache_threshold = 5
+
class BlockerData(object):
__slots__ = ("__weakref__", "atoms", "counter")
portage.CACHE_PATH.lstrip(os.path.sep), "vdb_blockers.pickle")
self._cache_version = "1"
self._cache_data = None
- self._modified = False
+ self._modified = 0
self._load()
def _load(self):
self._cache_data = {"version":self._cache_version}
self._cache_data["blockers"] = {}
self._cache_data["virtuals"] = self._virtuals
- self._modified = False
+ self._modified = 0
def flush(self):
"""If the current user has permission and the internal blocker cache
"virtuals" : vardb.settings.getvirtuals()
}
"""
- if self._modified and \
+ if self._modified >= self._cache_threshold and \
secpass >= 2:
try:
f = portage.util.atomic_ofstream(self._cache_filename)
self._cache_filename, gid=portage.portage_gid, mode=0644)
except (IOError, OSError), e:
pass
- self._modified = False
+ self._modified = 0
def __setitem__(self, cpv, blocker_data):
"""
"""
self._cache_data["blockers"][cpv] = \
(blocker_data.counter, tuple(str(x) for x in blocker_data.atoms))
- self._modified = True
+ self._modified += 1
def __iter__(self):
return iter(self._cache_data["blockers"])
def __delitem__(self, cpv):
del self._cache_data["blockers"][cpv]
- self._modified = True
def __getitem__(self, cpv):
"""