Cache invalidation for class or instance methods
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- backend-api-design
Research direction
Start with CacheRegion.cache_on_arguments and trace how its key generator handles decorated class and instance methods, then review the issue discussion before choosing between documentation and changed behavior. Done means the selected behavior is clearly documented, or the revised key handling is covered by tests for invalidate and set.
Written by the indexing model from the issue text.
Description
Migrated issue, originally created by David Beitey (davidjb)
When attempting to invalidate or set a value for a class or instance method that's being cached via CacheRegion.cache_on_arguments, the first argument passed to the decorated function's invalidate or set methods is ignored. For example, if I have
#!python
class Foo(object):
@cache.cache_on_arguments()
def do_something(self, text):
return text + 'dummy'
then if one wants to clear or set the cache for this method, they need to do this:
#!python
foo = Foo()
cached = foo.do_something('asdf')
foo.do_something.invalidate(anything_goes, 'asdf')
foo.do_something.set('value', anything_goes, 'asdf')
as the first argument passed into either function is ignored as part of the cache key.
This is probably expected behaviour for now, but I think the situation should be documented either way.
Since the first argument going into those invalidate/set is ignored regardless by the key generator, I think it would be easier to have the key generator use all arguments if the decorated method belongs to a class or instance. This would be far less prone to error as I've found when trying to clear such a cached method & forgetting the first argument.
- 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
-
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
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100