|
@ -49,14 +49,10 @@ class memoize(object): |
|
|
kw = sorted(kwargs.items()) |
|
|
kw = sorted(kwargs.items()) |
|
|
key = (args, tuple(kw)) |
|
|
key = (args, tuple(kw)) |
|
|
try: |
|
|
try: |
|
|
print("TRY CACHE") |
|
|
|
|
|
value = self.cache[key] |
|
|
value = self.cache[key] |
|
|
print("VALUE") |
|
|
|
|
|
if (current_time - value[1]) > self.timeout: |
|
|
if (current_time - value[1]) > self.timeout: |
|
|
print("TIMEOUT") |
|
|
|
|
|
raise KeyError |
|
|
raise KeyError |
|
|
except KeyError: |
|
|
except KeyError: |
|
|
print("NEW") |
|
|
|
|
|
value = self.cache[key] = (func(*args,**kwargs), current_time) |
|
|
value = self.cache[key] = (func(*args,**kwargs), current_time) |
|
|
return value[0] |
|
|
return value[0] |
|
|
return wrapper |
|
|
return wrapper |