Refactored Caching, Refactored BnfNodeParser, Introduced Sphinx
This commit is contained in:
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
from cache.Cache import Cache
|
||||
|
||||
|
||||
class IncCache(Cache):
|
||||
"""
|
||||
Increment the value of the key every time it's accessed
|
||||
"""
|
||||
|
||||
def _get(self, key):
|
||||
value = super()._get(key) or 0
|
||||
value += 1
|
||||
self._put(key, value)
|
||||
return value
|
||||
|
||||
def _put(self, key, value):
|
||||
self._cache[key] = value
|
||||
self._add_to_add(key)
|
||||
return True
|
||||
Reference in New Issue
Block a user