Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /bluesky_tiled /tests /test_resource_cache.py
| import cachetools | |
| from tiled.adapters.resource_cache import default_resource_cache, with_resource_cache | |
| def test_simple_cache(): | |
| counter = 0 | |
| def f(): | |
| nonlocal counter | |
| counter += 1 | |
| return "some value" | |
| cache = cachetools.Cache(maxsize=1) | |
| with_resource_cache("test_key", f, _resource_cache=cache) | |
| with_resource_cache("test_key", f, _resource_cache=cache) | |
| assert counter == 1 | |
| def test_default_cache(): | |
| counter = 0 | |
| def f(): | |
| nonlocal counter | |
| counter += 1 | |
| return "some value" | |
| cache = default_resource_cache() | |
| with_resource_cache("test_key", f, _resource_cache=cache) | |
| with_resource_cache("test_key", f, _resource_cache=cache) | |
| assert counter == 1 | |
| def test_cache_zero_size(): | |
| counter = 0 | |
| def f(): | |
| nonlocal counter | |
| counter += 1 | |
| return "some value" | |
| cache = cachetools.Cache(maxsize=0) | |
| with_resource_cache("test_key", f, _resource_cache=cache) | |
| with_resource_cache("test_key", f, _resource_cache=cache) | |
| assert counter == 2 | |
Xet Storage Details
- Size:
- 1.07 kB
- Xet hash:
- ea3619a7ceb123c6b1ba5a49931698f5400e9d8d05cc65b808f018849e77edad
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.