From b2a4ae6bc240eb5dade96bd807d762af734e671a Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Fri, 16 Jun 2017 00:41:38 +0200 Subject: [PATCH] lrucache: use explicit sentinel instead of None just in case someone wants to cache a big pile of nothing --- src/borg/lrucache.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/borg/lrucache.py b/src/borg/lrucache.py index 03db283f5..492e18b62 100644 --- a/src/borg/lrucache.py +++ b/src/borg/lrucache.py @@ -1,3 +1,6 @@ +sentinel = object() + + class LRUCache: def __init__(self, capacity, dispose): self._cache = {} @@ -29,9 +32,9 @@ class LRUCache: return key in self._cache def get(self, key, default=None): - value = self._cache.get(key, default) - if value is default: - return value + value = self._cache.get(key, sentinel) + if value is sentinel: + return default self._lru.remove(key) self._lru.append(key) return value