如何删除一个片段名称的所有缓存

relj7zay  于 2021-06-07  发布在  Redis
关注(0)|答案(0)|浏览(265)

嗨,我有一个django博客,我使用碎片兑现。我想删除片段缓存,但我有很多缓存。例如,我有很多文章,我不知道有多少
文章ID#1文章ID#2文章ID#3文章ID#4
我想删除我正在使用的所有cashe of article对象代码:

from django.core.cache import cache
from django.core.cache.utils import make_template_fragment_key

# cache key for {% cache 500 sidebar username %} templatetag

key = make_template_fragment_key('article', [article.id])
cache.delete(key) # invalidates cached template fragment

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题