question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

region.get does not respect object cache

See original GitHub issue
import 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:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
zzzeekcommented, Feb 19, 2019

result_2 = region.get(“foo-key”)

should be miss, fail

pprint(dict(result_2=result_2))

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:

{'result_1': 'foo-value'}
{'result_2': <dogpile.cache.api.NoValue object>}

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.


❯ python yolo.py {‘result_1’: ‘foo-value’} {‘result_2’: ‘foo-value’}


I expected something like

❯ python yolo.py {‘result_1’: ‘foo-value’} NO_VALIUE

0reactions
hugoduncancommented, Feb 21, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found