dogpile cache_on_arguments default key generation

95 views
Skip to first unread message

Jonathan Vanasco

unread,
Sep 18, 2012, 2:04:21 PM9/18/12
to pylons-...@googlegroups.com
i'm redoing dogpile caching on my app, and looking into cache_on_arguments

the docs say "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."

looking at the code, cache_on_arguments will create a cache key based on the args but not the kwargs.

is this the intended behavior ?  the decorator passes in all the kwargs, though I believe that is just to get the namespace and expiry info.

i just want to be sure that the default intended behavior was to interpret "arguments" as "args, but not kwargs"

mike bayer

unread,
Sep 18, 2012, 2:11:09 PM9/18/12
to pylons-...@googlegroups.com


On Tuesday, September 18, 2012 2:04:21 PM UTC-4, Jonathan Vanasco wrote:
i'm redoing dogpile caching on my app, and looking into cache_on_arguments

the docs say "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."

looking at the code, cache_on_arguments will create a cache key based on the args but not the kwargs.
 

is this the intended behavior ?  the decorator passes in all the kwargs, though I believe that is just to get the namespace and expiry info.

not sure which code you looked at, as the actual code that generates the key is here:

https://bitbucket.org/zzzeek/dogpile.cache/src/6c95329bb5a3/dogpile/cache/util.py#cl-58

and you'll see it explicitly raises an exception if **kw is present.   So yes, this is intentional.    the function is intended to be replaced with whatever you want via the function_key_generator argument passed to make_region().


 

Jonathan Vanasco

unread,
Sep 18, 2012, 2:25:05 PM9/18/12
to pylons-...@googlegroups.com
i'm not sure what i looked at either, but that's the answer i was hoping for.

i think i saw line in region.cache_on_arguments ( key = key_generator(*arg, **kw) ) and missed the valueerror in util

i also have a much older version of dogpile, as my line numbers are way off

anyways, great answer! thanks!

Michael Bayer

unread,
Sep 18, 2012, 2:45:00 PM9/18/12
to pylons-...@googlegroups.com
ah, well the whole thing is barely out of alpha so I'd definitely track the latest code ....


Reply all
Reply to author
Forward
0 new messages