aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-10-27 11:45:35 -0700
committerGitHub <noreply@github.com>2016-10-27 11:45:35 -0700
commita93baad6552f5da82398711d7e52197574820843 (patch)
treebcc540c0022ffc173cf903131d08377eb167acf3
parent4ab654748aad603d4431db2224668663f117a964 (diff)
parent6b4c705197e23da12a24486f0836e93cab6c806a (diff)
downloadmitmproxy-a93baad6552f5da82398711d7e52197574820843.tar.gz
mitmproxy-a93baad6552f5da82398711d7e52197574820843.tar.bz2
mitmproxy-a93baad6552f5da82398711d7e52197574820843.zip
Merge pull request #1680 from mhils/remove-lrucache
Remove mitmproxy.utils.lrucache
-rw-r--r--mitmproxy/utils/lrucache.py32
1 files changed, 0 insertions, 32 deletions
diff --git a/mitmproxy/utils/lrucache.py b/mitmproxy/utils/lrucache.py
deleted file mode 100644
index 7ad2b7f5..00000000
--- a/mitmproxy/utils/lrucache.py
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-class LRUCache:
-
- """
- A simple LRU cache for generated values.
- """
-
- def __init__(self, size=100):
- self.size = size
- self.cache = {}
- self.cacheList = []
-
- def get(self, gen, *args):
- """
- gen: A (presumably expensive) generator function. The identity of
- gen is NOT taken into account by the cache.
- *args: A list of immutable arguments, used to establish identiy by
- *the cache, and passed to gen to generate values.
- """
- if args in self.cache:
- self.cacheList.remove(args)
- self.cacheList.insert(0, args)
- return self.cache[args]
- else:
- ret = gen(*args)
- self.cacheList.insert(0, args)
- self.cache[args] = ret
- if len(self.cacheList) > self.size:
- d = self.cacheList.pop()
- self.cache.pop(d)
- return ret