Make the Region Invalidation Strategy more flexible
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
Research direction
Start by reading the RegionInvalidationStrategy interface and the Region methods mentioned in the issue: _is_cache_miss, _unexpired_value_fn, get_or_create, get_multi, and get. Trace how creation time reaches the strategy and compare the paths for each access method. Done means the strategy can use both the cache key and creation time consistently across those paths.
Written by the indexing model from the issue text.
Description
I have a use case where I can only determine if cache entry has expired by knowing the key and the time it was created.
As it stands the RegionInvalidationStrategy interface only receives the creation time.
If it was passed the key as well then I could implement the behaviour I need.
The use case is this:
I am querying the google analytics API, and caching the results in Redis. Although you can query for recent data, it is not guaranteed to be up to date.
The key is the datetime for the analytics data, I want to expire a cache entry if it was created less than a day after key (i.e it was recent data when it was created), but only if it is now more than an hour after it was created.
I have currently implemented this by overriding Region._is_cache_miss in a subclass. This is not great, because it only applies to the get_or_create class of methods, get_multi and get use self._unexpired_value_fn, which of course I could also override, but given RegionInvalidationStrategy is the proper way to manage invalidation I think it should be done there, and it also means it only has to be done in one place.
- Dominant language
- Python
- Stars
- 299
- Forks
- 50
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sqlalchemy/dogpile.cache
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
sqlalchemy/dogpile.cache#267 · 3 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
sqlalchemy/dogpile.cache#265 · 4 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
sqlalchemy/dogpile.cache#264 · 4 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
sqlalchemy/dogpile.cache#258 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 42/100
sqlalchemy/dogpile.cache#243 · 2 comments ·
All issues in sqlalchemy/dogpile.cache
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
simonw/sqlite-utils#872 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100