[entropy.db] EntropyRepository: validate Live cache against mtime()
Scenario: Process A is writing to EntropyRepository, adding new package entries. Process B is reading from EntropyRepository, querying for the same package entries, for example by using retrieveKeySlot(). This method uses a dict-based cache to speed up things, but this should be invalidated also when the mtime() value changes.
This commit is contained in:
@@ -538,6 +538,10 @@ class EntropyRepository(EntropyRepositoryBase):
|
||||
if self._db_path is None:
|
||||
raise AttributeError("valid database path needed")
|
||||
|
||||
# tracking mtime to validate repository Live cache as
|
||||
# well.
|
||||
self._cur_mtime = self.mtime()
|
||||
|
||||
# setup service interface
|
||||
self.__skip_checks = skipChecks
|
||||
|
||||
@@ -738,6 +742,10 @@ class EntropyRepository(EntropyRepositoryBase):
|
||||
self._live_cacher.set(self._getLiveCacheKey() + key, value)
|
||||
|
||||
def _getLiveCache(self, key):
|
||||
mtime = self.mtime()
|
||||
if self._cur_mtime != mtime:
|
||||
self._cur_mtime = mtime
|
||||
self._discardLiveCache()
|
||||
return self._live_cacher.get(self._getLiveCacheKey() + key)
|
||||
|
||||
def __del__(self):
|
||||
|
||||
Reference in New Issue
Block a user