0

i want to delete some specific data after model.save() fired. i use "post_save()" signal. when I use cache_page() decorator in my views.py, data will save in redis with keys like this: "prefix:1:views.decorators.cache.cache_header..8ce4de6051c3ba05396ff670741d3172.fa-ir.IRST'.

I want to save data with custom key that i specify. how can i do it?

or

how can i delete stored data that are related to specific url ?

url1: a/1/b/
url2: a/2/b/

how can i get data that are saved for url1?

msln
  • 1,318
  • 2
  • 19
  • 38

1 Answers1

0

Default function responsible for transforming cache key looks like this:

def make_key(key, key_prefix, version):
    return ':'.join([key_prefix, str(version), key])

via cache docs

So you would have to add key_prefix to your cache_page decorator

@cache_page(60 * 15, key_prefix="site1")
    def my_view(request):
    ...
mateuszb
  • 1,083
  • 10
  • 20
  • Ok, so I answered to the first part of the question (how to specify custom key), but unfortunately, I can't think of the way how you can achieve the second part. I'll leave the answer as it is. – mateuszb Jan 30 '17 at 20:17