Skip to content
Snippets Groups Projects
Commit 4f3e3ac1 authored by Erik Johnston's avatar Erik Johnston
Browse files

Correctly match 'dict.pop' api

parent 8ea88785
No related branches found
No related tags found
No related merge requests found
...@@ -98,10 +98,18 @@ class ExpiringCache(object): ...@@ -98,10 +98,18 @@ class ExpiringCache(object):
return entry.value return entry.value
def pop(self, key, default=None): def pop(self, key, default=SENTINEL):
value = self._cache.pop(key, SENTINEL) """Removes and returns the value with the given key from the cache.
If the key isn't in the cache then `default` will be returned if
specified, otherwise `KeyError` will get raised.
Identical functionality to `dict.pop(..)`.
"""
value = self._cache.pop(key, default)
if value is SENTINEL: if value is SENTINEL:
return default raise KeyError(key)
return value return value
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment