-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache decorator: option to explicitely ignore some parameters by name #201
Comments
I could see this feature as including 2 keyword arguments, each taking a list: |
That's nice to hear ! How would you integrate the current
I think it could be good to provide a Also as you can see in the current PR: #202 it is possible to exclude args as well as kwargs, so maybe |
Hello, After thinking a bit more about my pull request, I think that changing the way cache keys are computed might not be such a good idea. Maybe a better approach would be to only use the new method if |
Haha I've completely given up on this (was even for a previous job). Turned out beaker was not the best tool for what we were doing, we ended using http://www.grantjenks.com/docs/diskcache/ and a custom wrapper. |
I added some additional packaging to him, achieving my goal redis_config = commonConfig["redis"]
cache_opts = {
'cache.type': 'ext:redis',
'cache.url': f"redis://default:{redis_config['password']}@{redis_config['host']}:{redis_config['port']}",
'cache.prefix': "file"
}
_cache = CacheManager(**cache_opts)
def cache(*cache_args, **cache_kwargs):
def decorator(f):
@wraps(f)
def decorated(*args, **kwargs):
__args = []
for arg in args:
if not isinstance(arg, Session):
__args.append(arg)
@_cache.cache(*cache_args, **cache_kwargs)
def __cache(*_args, **_kwargs):
return f(*args, **kwargs)
return __cache(*__args, **kwargs)
return decorated
return decorator |
Hello,
we are in the need of a feature where we could explicitly ignore some arguments of a cached function (by argument name). Would you be interested in integrating such a feature into beaker ?
What are the current requirements for a pull request ?
Thank you/
The text was updated successfully, but these errors were encountered: