python类delete_many()的实例源码

tests.py 文件源码 项目:django-lrucache-backend 作者: kogan 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_delete_many(self):
        # Multiple keys can be deleted using delete_many
        cache = self.cache
        cache.set("key1", "spam")
        cache.set("key2", "eggs")
        cache.set("key3", "ham")
        cache.delete_many(["key1", "key2"])
        self.assertIsNone(cache.get("key1"))
        self.assertIsNone(cache.get("key2"))
        self.assertEqual(cache.get("key3"), "ham")
choices.py 文件源码 项目:DjangoCMS 作者: farhan711 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def _clean_many(prefix):
    from django.core.cache import cache
    keys = []
    if settings.USE_I18N:
        for lang in [language[0] for language in settings.LANGUAGES]:
            keys.append("%s-%s" %(prefix, lang))
    else:
        keys = ["%s-%s" %(prefix, settings.LANGUAGE_CODE)]
    cache.delete_many(keys)
tests.py 文件源码 项目:django-asyncio-redis 作者: mackeyja92 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_delete_many(self):
        await self.set('test', 'test-1')
        await self.set('test2', 'test-2')
        await cache.delete_many(('test-1', 'test-2'))
        self.assertIsNone(await self.get('test-1'))
        self.assertIsNone(await self.get('test-2'))
service.py 文件源码 项目:PureWhiteBlog 作者: PureWhiteWu 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def invalidate_object_cache(cls, instance):
        # TODO: Think about raise condition
        # if new invalidation created when invalidating
        # what will happen?
        keys = cls.get_invalidation_keys_and_delete(instance)
        cache.delete_many(keys)
signals.py 文件源码 项目:perdiem-django 作者: RevolutionTech 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def clear_all_profile_contexts(sender, instance, **kwargs):
    # TODO(lucas): Review to improve performance
    # Instead of clearing out all of the profile contexts, we could just clear out
    # the profile contexts associated with the investors related to this revenue report
    cache_keys = ['profile_context-{pk}'.format(pk=up.pk) for up in UserProfile.objects.all()]
    cache.delete_many(cache_keys)
statistics.py 文件源码 项目:eoj3 作者: ultmaster 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def invalidate_contest(contest: Contest):
    contest_users = contest.participants_ids
    cache.delete_many(list(map(lambda x: PARTICIPANT_RANK_DETAIL.format(contest=contest.pk, user=x), contest_users)))
    cache.delete_many(
        list(map(lambda x: PARTICIPANT_RANK_DETAIL_PRIVATE.format(contest=contest.pk, user=x), contest_users)))
    cache.delete(PARTICIPANT_RANK_LIST.format(contest=contest.pk))
    cache.delete(CONTEST_FIRST_YES.format(contest=contest.pk))
statistics.py 文件源码 项目:eoj3 作者: ultmaster 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def invalidate_user(user_id, contest_id=0):
    cache.delete_many([USER_TOTAL_COUNT.format(user=user_id, contest=contest_id),
                       USER_TOTAL_LIST.format(user=user_id, contest=contest_id),
                       USER_AC_COUNT.format(user=user_id, contest=contest_id),
                       USER_AC_DIFF_COUNT.format(user=user_id, contest=contest_id),
                       USER_AC_LIST.format(user=user_id, contest=contest_id)])


问题


面经


文章

微信
公众号

扫码关注公众号