Implemented SheerkaOntology
This commit is contained in:
Vendored
+10
-4
@@ -1,4 +1,5 @@
|
||||
from cache.Cache import Cache
|
||||
from core.global_symbols import NotFound, Removed
|
||||
|
||||
|
||||
class IncCache(Cache):
|
||||
@@ -6,13 +7,18 @@ class IncCache(Cache):
|
||||
Increment the value of the key every time it's accessed
|
||||
"""
|
||||
|
||||
def _get(self, key):
|
||||
value = super()._get(key) or 0
|
||||
def _get(self, key, alt_sdp=None):
|
||||
value = super()._get(key, alt_sdp=alt_sdp)
|
||||
if value in (NotFound, Removed):
|
||||
value = 0
|
||||
value += 1
|
||||
self._put(key, value)
|
||||
self._put(key, value, alt_sdp)
|
||||
return value
|
||||
|
||||
def _put(self, key, value):
|
||||
def _put(self, key, value, alt_sdp):
|
||||
self._cache[key] = value
|
||||
self._add_to_add(key)
|
||||
return True
|
||||
|
||||
def _alt_get(self, key):
|
||||
return super()._get(key) # point to parent, not to self
|
||||
|
||||
Reference in New Issue
Block a user