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
+13 -1
View File
@@ -1,4 +1,5 @@
from cache.FastCache import FastCache
from core.global_symbols import NotFound
def test_i_can_put_an_retrieve_values():
@@ -47,7 +48,7 @@ def test_i_can_put_the_same_key_several_times():
def test_none_is_returned_when_not_found():
cache = FastCache()
assert cache.get("foo") is None
assert cache.get("foo") is NotFound
def test_i_can_evict_by_key():
@@ -65,3 +66,14 @@ def test_i_can_evict_by_key():
"to_keep3": "to_keep_value3"}
assert cache.lru == ["to_keep1", "to_keep2", "to_keep3"]
def test_i_can_get_default_value():
cache = FastCache(max_size=3, default=lambda key: key + 1)
assert cache.get(1) == 2
assert cache.get(2) == 3
assert cache.get(3) == 4
assert cache.get(4) == 5
assert cache.cache == {2: 3, 3: 4, 4: 5} # only 3 values