-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ML-2572: Fix caching bug * Minor refactoring * Fix GC bug + optimizations + locking + tests * Add puts to same key * Improve tests
- Loading branch information
Gal Topper
authored
Sep 7, 2022
1 parent
19a00c4
commit 8b5d747
Showing
2 changed files
with
50 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from v3iofs.fs import _Cache | ||
|
||
|
||
def test_put_and_get(): | ||
cache = _Cache(10, 100) | ||
cache.put("k1", "v1") | ||
cache.put("k2", "v2") | ||
cache.put("k3", "v3.1") | ||
cache.put("k3", "v3.2") | ||
assert cache.get("k1") == "v1" | ||
assert cache.get("k2") == "v2" | ||
assert cache.get("k3") == "v3.2" | ||
|
||
|
||
def test_invalidation_and_gc(): | ||
cache = _Cache(10, 0) | ||
cache.put("k1", "v1") | ||
cache.put("k2", "v2") | ||
cache.put("k3", "v3.1") | ||
cache.put("k3", "v3.2") | ||
assert cache.get("k1") is None | ||
assert cache.get("k2") is None | ||
assert cache.get("k3") is None | ||
assert cache._cache == {} | ||
assert cache._expiry_to_key == [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters