Skip to content
Snippets Groups Projects
Commit 45463744 authored by Pierre LALET's avatar Pierre LALET
Browse files

CacheInstance: use timestamp in .update()

parent 317ed35e
No related branches found
No related tags found
No related merge requests found
......@@ -201,8 +201,12 @@ class CacheInstance(dict, object):
self._timetable[item] = time.time()
dict.__setitem__(self, item,v)
def update(self, other):
dict.update(self, other)
self._timetable.update(other._timetable)
for key, value in other.iteritems():
# We only update an element from `other` either if it does
# not exist in `self` or if the entry in `self` is older.
if key not in self or self._timetable[key] < other._timetable[key]:
dict.__setitem__(self, key, value)
self._timetable[key] = other._timetable[key]
def iteritems(self):
if self.timeout is None:
return six.iteritems(self.__dict__)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment