本文整理汇总了Python中django.core.cache.cache.delete_many方法的典型用法代码示例。如果您正苦于以下问题:Python cache.delete_many方法的具体用法?Python cache.delete_many怎么用?Python cache.delete_many使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.core.cache.cache
的用法示例。
在下文中一共展示了cache.delete_many方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: problem_update
# 需要导入模块: from django.core.cache import cache [as 别名]
# 或者: from django.core.cache.cache import delete_many [as 别名]
def problem_update(sender, instance, **kwargs):
if hasattr(instance, '_updating_stats_only'):
return
cache.delete_many([
make_template_fragment_key('submission_problem', (instance.id,)),
make_template_fragment_key('problem_feed', (instance.id,)),
'problem_tls:%s' % instance.id, 'problem_mls:%s' % instance.id,
])
cache.delete_many([make_template_fragment_key('problem_html', (instance.id, engine, lang))
for lang, _ in settings.LANGUAGES for engine in EFFECTIVE_MATH_ENGINES])
cache.delete_many([make_template_fragment_key('problem_authors', (instance.id, lang))
for lang, _ in settings.LANGUAGES])
cache.delete_many(['generated-meta-problem:%s:%d' % (lang, instance.id) for lang, _ in settings.LANGUAGES])
for lang, _ in settings.LANGUAGES:
unlink_if_exists(get_pdf_path('%s.%s.pdf' % (instance.code, lang)))
示例2: profile_update
# 需要导入模块: from django.core.cache import cache [as 别名]
# 或者: from django.core.cache.cache import delete_many [as 别名]
def profile_update(sender, instance, **kwargs):
if hasattr(instance, '_updating_stats_only'):
return
cache.delete_many([make_template_fragment_key('user_about', (instance.id, engine))
for engine in EFFECTIVE_MATH_ENGINES] +
[make_template_fragment_key('org_member_count', (org_id,))
for org_id in instance.organizations.values_list('id', flat=True)])
示例3: contest_update
# 需要导入模块: from django.core.cache import cache [as 别名]
# 或者: from django.core.cache.cache import delete_many [as 别名]
def contest_update(sender, instance, **kwargs):
if hasattr(instance, '_updating_stats_only'):
return
cache.delete_many(['generated-meta-contest:%d' % instance.id] +
[make_template_fragment_key('contest_html', (instance.id, engine))
for engine in EFFECTIVE_MATH_ENGINES])
示例4: language_update
# 需要导入模块: from django.core.cache import cache [as 别名]
# 或者: from django.core.cache.cache import delete_many [as 别名]
def language_update(sender, instance, **kwargs):
cache.delete_many([make_template_fragment_key('language_html', (instance.id,)),
'lang:cn_map'])
示例5: post_update
# 需要导入模块: from django.core.cache import cache [as 别名]
# 或者: from django.core.cache.cache import delete_many [as 别名]
def post_update(sender, instance, **kwargs):
cache.delete_many([
make_template_fragment_key('post_summary', (instance.id,)),
'blog_slug:%d' % instance.id,
'blog_feed:%d' % instance.id,
])
cache.delete_many([make_template_fragment_key('post_content', (instance.id, engine))
for engine in EFFECTIVE_MATH_ENGINES])
示例6: misc_config_cache_delete
# 需要导入模块: from django.core.cache import cache [as 别名]
# 或者: from django.core.cache.cache import delete_many [as 别名]
def misc_config_cache_delete(key):
cache.delete_many(['misc_config:%s:%s:%s' % (domain, lang, key.split('.')[0])
for lang in _misc_config_i18n
for domain in Site.objects.values_list('domain', flat=True)])
示例7: finished_submission
# 需要导入模块: from django.core.cache import cache [as 别名]
# 或者: from django.core.cache.cache import delete_many [as 别名]
def finished_submission(sub):
keys = ['user_complete:%d' % sub.user_id, 'user_attempted:%s' % sub.user_id]
if hasattr(sub, 'contest'):
participation = sub.contest.participation
keys += ['contest_complete:%d' % participation.id]
keys += ['contest_attempted:%d' % participation.id]
cache.delete_many(keys)
示例8: save
# 需要导入模块: from django.core.cache import cache [as 别名]
# 或者: from django.core.cache.cache import delete_many [as 别名]
def save(self, *args, **kwargs):
super().save(*args, **kwargs)
cache.delete_many(self._bulk_invalidation_cache_keys)
示例9: test_delete_many
# 需要导入模块: from django.core.cache import cache [as 别名]
# 或者: from django.core.cache.cache import delete_many [as 别名]
def test_delete_many(self):
# Multiple keys can be deleted using delete_many
cache.set("key1", "spam")
cache.set("key2", "eggs")
cache.set("key3", "ham")
with self.assertNumQueries(1):
cache.delete_many(["key1", "key2"])
assert cache.get("key1") is None
assert cache.get("key2") is None
assert cache.get("key3") == "ham"
示例10: revoke_user_course_permissions
# 需要导入模块: from django.core.cache import cache [as 别名]
# 或者: from django.core.cache.cache import delete_many [as 别名]
def revoke_user_course_permissions(user):
"""
Revokes all course permissions for the given user.
Arguments
user (User) -- User for which permissions should be revoked
"""
cache.delete_many(_get_course_permission_cache_keys(user))
示例11: invalidate_schematics
# 需要导入模块: from django.core.cache import cache [as 别名]
# 或者: from django.core.cache.cache import delete_many [as 别名]
def invalidate_schematics(self):
cache.delete_many([self.name + "_cons_schematic",self.name + "_wt_schematic",self.name + "_chem_summary"])
self.schematics = None
self.save()
示例12: save
# 需要导入模块: from django.core.cache import cache [as 别名]
# 或者: from django.core.cache.cache import delete_many [as 别名]
def save(self, *args, **kwargs):
super(Instagram, self).save(*args, **kwargs)
cache_keys = (
self.get_cache_key(prefix='profile_%s' % self.user_id.strip()),
self.get_cache_key(prefix='profile_%s' % self.account.uid),
self.get_cache_key(prefix='location_%s' % self.location_id.strip()),
self.get_cache_key(prefix='media'),
)
cache.delete_many(cache_keys)
示例13: clear_cache
# 需要导入模块: from django.core.cache import cache [as 别名]
# 或者: from django.core.cache.cache import delete_many [as 别名]
def clear_cache(model):
cache_object_key = helper.cache_object_key(model)
obj_methods_caches = django_cache.get(cache_object_key)
methods_key = obj_methods_caches.split('|')
django_cache.delete_many(methods_key)
示例14: remove_cleaned_articles
# 需要导入模块: from django.core.cache import cache [as 别名]
# 或者: from django.core.cache.cache import delete_many [as 别名]
def remove_cleaned_articles(articles):
cache.delete_many([cache_id_to_key(a.id) for a in articles])