_excluded_dirs = re.compile(r'^(\..*|-MERGING-.*|' + \
"|".join(_excluded_dirs) + r')$')
+ # Number of uncached packages to trigger cache update, since
+ # it's wasteful to update it for every vdb change.
+ _aux_cache_threshold = 5
+
_aux_multi_line_re = re.compile(r'^(CONTENTS|NEEDED\..*)$')
"""
users have read access and benefit from faster metadata lookups (as
long as at least part of the cache is still valid)."""
if self._aux_cache is not None and \
- self._aux_cache["modified"] and \
+ self._aux_cache["modified"] >= self._aux_cache_threshold and \
secpass >= 2:
valid_nodes = set(self.cpv_all())
for cpv in self._aux_cache["packages"].keys():
self._aux_cache_filename, gid=portage_gid, mode=0644)
except (IOError, OSError), e:
pass
- self._aux_cache["modified"] = False
+ self._aux_cache["modified"] = 0
def aux_get(self, mycpv, wants):
"""This automatically caches selected keys that are frequently needed
not self._aux_cache.get("packages"):
self._aux_cache = {"version": self._aux_cache_version}
self._aux_cache["packages"] = {}
- self._aux_cache["modified"] = False
+ self._aux_cache["modified"] = 0
mydir = os.path.join(self.root, VDB_PATH, mycpv)
mydir_stat = None
try:
for aux_key in cache_these:
cache_data[aux_key] = mydata[aux_key]
self._aux_cache["packages"][mycpv] = (mydir_mtime, cache_data)
- self._aux_cache["modified"] = True
+ self._aux_cache["modified"] += 1
return [mydata[x] for x in wants]
def _aux_get(self, mycpv, wants):