region.get does not respect object cache
See original GitHub issueimport time
from pprint import pprint
from dogpile.cache.region import make_region
region = make_region().configure("dogpile.cache.memory")
region.get_or_create("foo-key", lambda: "foo-value", expiration_time=2)
time.sleep(1)
result_1 = region.get("foo-key")
# should be hit, ok
pprint(dict(result_1=result_1))
time.sleep(2)
result_2 = region.get("foo-key")
# should be miss, fail
pprint(dict(result_2=result_2))
❯ python yolo.py
{'result_1': 'foo-value'}
{'result_2': 'foo-value'}
I expected something like
❯ python yolo.py
{'result_1': 'foo-value'}
NO_VALIUE
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Avoiding multiple repopulations of the same cache region ...
I'm not quite sure, but: It allows concurrent read access to elements already in the cache. If the element is null, other reads...
Read more >ObjectCache Class (System.Runtime.Caching) - Microsoft Learn
Gets a value that indicates that a cache entry has no absolute expiration. NoSlidingExpiration. Indicates that a cache entry has no sliding expiration...
Read more >Caching - Akamai TechDocs
Cache-Control: no-cache works with browser caches. In the Force revalidation of stale objects field, specify what to do when an object's caching life...
Read more >Introducing Cache Reserve: massively extending Cloudflare's ...
I'm delighted to announce an extension of the benefits of caching with Cache Reserve: a new way to persistently serve all static content ......
Read more >Torque ORM Reference - Managers and Caching
Business Object Cache. If the no-arg constructor of FooManager calls setRegion(region) where the String region is the key used to determine ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
the value is not expired because you have not specified an expiration time.
call it like this:
result_2 = region.get("foo-key", expiration_time=2)
then you get:so it would appear I need to add a note to the “expiration_time” argument to get() that this is a per-get expiration time, it is not stored with the object. dogpile doesn’t store per-object expiration times.
Thanks for taking the time to put together the thorough summary above. What you’ve described sounds like a good approach, but I don’t think we’ll have time to do such a broad update. Look forward to seeing if this gets picked up in the future.