Browse Source

lrucache: use explicit sentinel instead of None

just in case someone wants to cache a big pile of nothing
Marian Beermann 8 years ago
parent
commit
b2a4ae6bc2
1 changed files with 6 additions and 3 deletions
  1. 6 3
      src/borg/lrucache.py

+ 6 - 3
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