Implemented SheerkaOntology

This commit is contained in:
2021-01-11 15:36:03 +01:00
parent e3c2adb533
commit e26c83a825
119 changed files with 6876 additions and 2002 deletions
+10 -4
View File
@@ -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