Issue #110 new
Tudor Aursulesei
created an issue

how does dogpile.cache's cache_on_arguments handle a decorated class method? What if the second decorator contains some fixed args and kwargs? Which of these is put in the key? I've had to deal with this and the second decorator doesn't have the functools.wrap magic attached so it confuses dogpile.cache - i received wrong cache data.

I've added a namespace and everything seems to work. Is this expected? How can i prevent this in the future in a safer way?

Comments (2)

  1. Michael Bayer repo owner

    per http://dogpilecache.readthedocs.io/en/latest/api.html#dogpile.cache.region.CacheRegion.cache_on_arguments

    "The namespace parameter is optional, and is used normally to disambiguate two functions of the same name within the same module, as can occur when decorating instance or class methods as below:"

    "namespace¶ – optional string argument which will be established as part of the cache key. This may be needed to disambiguate functions of the same name within the same source file, such as those associated with classes - note that the decorator itself can’t see the parent class on a function as the class is being declared."

    so....seems expected? not sure what your specific issue is without an example.

  2. Tudor Aursulesei reporter

    I've managed to get dogpile.cache mix up cached results from two different class methods. Both of the methods had another decorator under cache_on_arguments. I'm working on a minimal example. I've meanwhile repaired the second decorator to use a @Wraps and the problem went away. Putting a namespace into the decorator also worked but it was not elegant.

  3. Log in to comment