Fix "memoized" helper when "expire" is not used

This commit is contained in:
Ivan Kravets
2018-05-25 21:13:47 +03:00
parent 357c932a88
commit e48e15b014

View File

@ -122,7 +122,8 @@ class memoized(object):
def wrapper(*args, **kwargs):
key = str(args) + str(kwargs)
if (key not in self.cache
or self.cache[key][0] < time.time() - self.expire):
or (self.expire > 0
and self.cache[key][0] < time.time() - self.expire)):
self.cache[key] = (time.time(), func(*args, **kwargs))
return self.cache[key][1]