django-cache-memoize icon indicating copy to clipboard operation
django-cache-memoize copied to clipboard

Feature Request: extra key components

Open pySilver opened this issue 4 years ago • 2 comments

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

pySilver avatar Mar 30 '21 02:03 pySilver

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 avatar May 11 '23 07:05 raiyankamal

@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.

pySilver avatar May 11 '23 12:05 pySilver