This adds a cache on top of our query to resultsdb that currently does nothing at all. The backend for dogpile.cache is set to the null backend, which means nothing will be cached.
dogpile.cache
null
This is a step in the road to get us to #77.
Why not just use the dogpile.cache-provided decorator?
dogpile.cache also provides a set of key generators you can use in place of the default.
I only wanted control over the key generator. I can probably get that without writing my own @cached decorator here - you're right.
@cached
Ah, right, because here I have the cache region attached to flask.current_app which isn't globally available to a decorator at import time.
flask.current_app
1 new commit added
OK, @jcline. 7dfa99e68c7d53e50e07221b1c7b2e035a00e3f0 should simplify it a bit.
I recommend adding function arg, return value, and exception docs here, but it's up to you.
Same deal here with the docs
Looks good to me :thumbsup:, just two minor optional comments
Thanks. Let's see what @mjia and @dcallagh want. I'll add them if they want - or won't if they don't.
As I understand, you do not need to explicitly set function_key_generator here as dogpile.cache.util.function_key_generator is the default key generator. BTW, is there any way to see the cached keys? I only found a paragraph about this in the docs[1]:
"The default key generation will use the name of the function, the module name for the function, the arguments passed, as well as an optional “namespace” parameter in order to generate a cache key."
[1] https://dogpilecache.readthedocs.io/en/latest/usage.html
I'm okay with this.
After reading the last comment from Ralph in greenweave#77, I understand why it is using a convenient alias here as we are also going to use it to retrieve the cached key in the fedmsg consumer. All looks good to me, :-P
Cool. I think that's a :+1: from @mjia. Good to merge?
Sure, I'm going to hit the button, :-)
Pull-Request has been merged by mjia
woot!
This adds a cache on top of our query to resultsdb that currently does
nothing at all. The backend for
dogpile.cacheis set to thenullbackend, which means nothing will be cached.
This is a step in the road to get us to #77.