cache_on_arguments invalidate in case of classmethod

Issue #52 duplicate
created an issue

I have following declaration:

class Takeover(db.Model, ModelMixin):
    def get_by_category_id(cls, category_id):

And I use it like this Takeover.get_by_category_id(5). Now I decided to invalidate it. It would be natural to invalidate it based on actual parameters, like this Takeover.get_by_category_id.invalidate(5), but it doesn't work, because key_generator assumes that it "has_self" (cls in this case) and drops out the first param. I think this should work differently, because it is counterintuitive and your own doc adds to confusion: "Pass to invalidate() the same arguments you’d pass to the function itself to represent a particular value".

Comments (2)

  1. Michael Bayer repo owner

    there's some complexities to resolving this described at #24 though possibly some "better than nothing" solutions could be devised (basically the key generation method should have access to self or cls, in case it is significant to the key generator. but this seems not possible for an invalidator).

  2. Log in to comment