django-cache-memoize
django-cache-memoize copied to clipboard
Feature Request: extra key components
Sometimes we know, that cache state should depend on some external data like some dependency last update datetime. It would be nice if extra args would be supported so one can pass smth like
@cache_memoize(60, extra=('foo', obj.pk, foo.unix_timestamp))
def foo(*args, **kwargs):
return 42
This also solves #35
Could the key_generator_callable help in this case?
https://github.com/peterbe/django-cache-memoize/blob/ef449fee0d90daac87ca709fa2e3d00b150f7725/src/cache_memoize/init.py#L20
@raiyankamal yes and no. It is quickly become tedious when you need this extra parameters in literally every usage of the decorator. Such as when you want your cache to be versioned.