0

We can cache any view/non-view function as

@cache.cached(timeout=50, key_prefix='all_comments')

Can we give key_prefix some variable values. Let say, I'm caching a function as

@cache.cached(timeout=50, key_prefix=value)
def get_all_comments(value):

Can we give key_prefix as the same arguments as we are getting in function. If not argument, then atleast some other variable by any proper way.

a.m.
  • 2,083
  • 1
  • 16
  • 22

1 Answers1

1

In the docs it says

New in version 0.3.4: Can optionally be a callable which takes no arguments but returns a string that will be used as the cache_key.

Sean Vieira
  • 155,703
  • 32
  • 311
  • 293