Store transaction counter on local cache
As the cache is shared with many instances, the counter must also be shared. review599004
This commit is contained in:
1 parent
1cdf1ffaef
commit
489e297cf2
1 file changed
+3
-3
@@ -1123,7 +1123,7 @@ class ModelStorage(Model):
|
||||
self._local_cache = _local_cache
|
||||
else:
|
||||
self._local_cache = LRUDict(RECORD_CACHE_SIZE)
|
||||
self._local_counter = Transaction().counter
|
||||
self._local_cache.counter = Transaction().counter
|
||||
|
||||
@property
|
||||
def _cache(self):
|
||||
@@ -1140,9 +1140,9 @@ class ModelStorage(Model):
|
||||
raise
|
||||
|
||||
counter = Transaction().counter
|
||||
if self._local_counter != counter:
|
||||
if self._local_cache.counter != counter:
|
||||
self._local_cache.clear()
|
||||
self._local_counter = counter
|
||||
self._local_cache.counter = counter
|
||||
try:
|
||||
return self._local_cache[self.id][name]
|
||||
except KeyError:
|
||||
|
||||
Reference in new issue
Block a user