本文整理汇总了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;未经允许,请勿转载。 |
请发表评论