• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python cache.delete函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sentry.utils.cache.cache.delete函数的典型用法代码示例。如果您正苦于以下问题:Python delete函数的具体用法?Python delete怎么用?Python delete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了delete函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __post_save

    def __post_save(self, instance, **kwargs):
        """
        Pushes changes to an instance into the cache, and removes invalid (changed)
        lookup values.
        """
        pk_name = instance._meta.pk.name
        pk_names = ("pk", pk_name)
        pk_val = instance.pk
        for key in self.cache_fields:
            if key in pk_names:
                continue
            # store pointers
            cache.set(self.__get_lookup_cache_key(**{key: getattr(instance, key)}), pk_val, self.cache_ttl)  # 1 hour

        # Ensure we dont serialize the database into the cache
        db = instance._state.db
        instance._state.db = None
        # store actual object
        cache.set(self.__get_lookup_cache_key(**{pk_name: pk_val}), instance, self.cache_ttl)
        instance._state.db = db

        # Kill off any keys which are no longer valid
        if instance in self.__cache:
            for key in self.cache_fields:
                if key not in self.__cache[instance]:
                    continue
                value = self.__cache[instance][key]
                if value != getattr(instance, key):
                    cache.delete(self.__get_lookup_cache_key(**{key: value}))

        self.__cache_state(instance)
开发者ID:turleyhari,项目名称:sentry,代码行数:31,代码来源:manager.py


示例2: unset_value

 def unset_value(self, instance, key):
     self.filter(**{self.field_name: instance, 'key': key}).delete()
     if instance.pk not in self.__metadata:
         cache.delete(self._make_key(instance))
         return
     self.__metadata[instance.pk].pop(key, None)
     cache.set(self._make_key(instance), self.__metadata[instance.pk])
开发者ID:Tug,项目名称:sentry,代码行数:7,代码来源:manager.py


示例3: __post_delete

 def __post_delete(self, instance, **kwargs):
     """
     Drops instance from all cache storages.
     """
     pk_name = instance._meta.pk.name
     for key in self.cache_fields:
         if key in ("pk", pk_name):
             continue
         # remove pointers
         cache.delete(self.__get_lookup_cache_key(**{key: getattr(instance, key)}))
     # remove actual object
     cache.delete(self.__get_lookup_cache_key(**{pk_name: instance.pk}))
开发者ID:turleyhari,项目名称:sentry,代码行数:12,代码来源:manager.py


示例4: __post_delete

 def __post_delete(self, instance, **kwargs):
     """
     Drops instance from all cache storages.
     """
     pk_name = instance._meta.pk.name
     for key in self.cache_fields:
         if key in ("pk", pk_name):
             continue
         # remove pointers
         value = self.__value_for_field(instance, key)
         cache.delete(key=self.__get_lookup_cache_key(**{key: value}), version=self.cache_version)
     # remove actual object
     cache.delete(key=self.__get_lookup_cache_key(**{pk_name: instance.pk}), version=self.cache_version)
开发者ID:ForkRepo,项目名称:sentry,代码行数:13,代码来源:manager.py


示例5: __post_save

    def __post_save(self, instance, **kwargs):
        """
        Pushes changes to an instance into the cache, and removes invalid (changed)
        lookup values.
        """
        pk_name = instance._meta.pk.name
        pk_names = ('pk', pk_name)
        pk_val = instance.pk
        for key in self.cache_fields:
            if key in pk_names:
                continue
            # store pointers
            value = self.__value_for_field(instance, key)
            cache.set(
                key=self.__get_lookup_cache_key(**{key: value}),
                value=pk_val,
                timeout=self.cache_ttl,
                version=self.cache_version,
            )

        # Ensure we don't serialize the database into the cache
        db = instance._state.db
        instance._state.db = None
        # store actual object
        try:
            cache.set(
                key=self.__get_lookup_cache_key(**{pk_name: pk_val}),
                value=instance,
                timeout=self.cache_ttl,
                version=self.cache_version,
            )
        except Exception as e:
            logger.error(e, exc_info=True)
        instance._state.db = db

        # Kill off any keys which are no longer valid
        if instance in self.__cache:
            for key in self.cache_fields:
                if key not in self.__cache[instance]:
                    continue
                value = self.__cache[instance][key]
                current_value = self.__value_for_field(instance, key)
                if value != current_value:
                    cache.delete(
                        key=self.__get_lookup_cache_key(**{key: value}),
                        version=self.cache_version,
                    )

        self.__cache_state(instance)
开发者ID:NuttasitBoonwat,项目名称:sentry,代码行数:49,代码来源:manager.py


示例6: set_value

    def set_value(self, instance, key, value):
        inst, created = self.get_or_create(**{
            self.field_name: instance,
            'key': key,
            'defaults': {
                'value': value,
            }
        })
        if not created and inst.value != value:
            inst.update(value=value)

        if instance.pk not in self.__metadata:
            cache.delete(self._make_key(instance))
            return
        self.__metadata[instance.pk][key] = value
        cache.set(self._make_key(instance), self.__metadata[instance.pk])
开发者ID:Tug,项目名称:sentry,代码行数:16,代码来源:manager.py


示例7: uncache_object

 def uncache_object(self, instance_id):
     pk_name = self.model._meta.pk.name
     cache_key = self.__get_lookup_cache_key(**{pk_name: instance_id})
     cache.delete(cache_key, version=self.cache_version)
开发者ID:ForkRepo,项目名称:sentry,代码行数:4,代码来源:manager.py


示例8: _get_cache_key

    def _get_cache_key(self, group_id, environment_id):
        return 'groupenv:1:{}:{}'.format(group_id, environment_id)

    @classmethod
    def get_or_create(cls, group_id, environment_id, defaults=None):
        cache_key = cls._get_cache_key(group_id, environment_id)
        instance = cache.get(cache_key)
        if instance is None:
            instance, created = cls.objects.get_or_create(
                group_id=group_id,
                environment_id=environment_id,
                defaults=defaults,
            )
            cache.set(cache_key, instance, 3600)
        else:
            created = False

        return instance, created


post_delete.connect(
    lambda instance, **kwargs: cache.delete(
        GroupEnvironment._get_cache_key(
            instance.group_id,
            instance.environment_id,
        ),
    ),
    sender=GroupEnvironment,
    weak=False,
)
开发者ID:binlee1990,项目名称:sentry,代码行数:30,代码来源:groupenvironment.py


示例9: save

 def save(self, *args, **kwargs):
     rv = super(Rule, self).save(*args, **kwargs)
     cache_key = 'project:{}:rules'.format(self.project_id)
     cache.delete(cache_key)
     return rv
开发者ID:Cobbyzhang,项目名称:sentry,代码行数:5,代码来源:rule.py



注:本文中的sentry.utils.cache.cache.delete函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python cache.get函数代码示例发布时间:2022-05-27
下一篇:
Python avatar.get_gravatar_url函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap