summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Hutchinson <jlhutch@gmail.com>2015-03-18 01:54:15 -0500
committerJay Hutchinson <jlhutch@gmail.com>2015-03-18 02:11:41 -0500
commit7bdea5954a537245ecb5b9bb6cb446805f7e2578 (patch)
treec3cefc26820a3c99669afb4f00c4d81c0ed195dd
parent7962de72de04b3dc4d3701f80c1de6ae155cd85f (diff)
downloadpylru-7bdea5954a537245ecb5b9bb6cb446805f7e2578.tar.gz
Refactored lrudecorator using FunctionCacheManager.
-rw-r--r--pylru.py16
1 files changed, 2 insertions, 14 deletions
diff --git a/pylru.py b/pylru.py
index 1e23ba2..5cb4130 100644
--- a/pylru.py
+++ b/pylru.py
@@ -534,19 +534,7 @@ def lruwrap(store, size, writeback=False):
class lrudecorator(object):
def __init__(self, size):
- self.cache = lrucache(size)
+ self.size = size
def __call__(self, func):
- def wrapped(*args, **kwargs):
- kwtuple = tuple((key, kwargs[key]) for key in sorted(kwargs.keys()))
- key = (args, kwtuple)
- try:
- return self.cache[key]
- except KeyError:
- pass
-
- value = func(*args, **kwargs)
- self.cache[key] = value
- return value
- wrapped.cache = self.cache
- return wrapped
+ return FunctionCacheManager(func, self.size)