本文整理汇总了Python中r2.config.cache.delete函数的典型用法代码示例。如果您正苦于以下问题:Python delete函数的具体用法?Python delete怎么用?Python delete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delete函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cached_query
def cached_query(query, sr):
"""Returns the results from running query. The results are cached and
only recomputed after 'expire_delta'"""
query._limit = 150
query._write_cache = True
iden = query._iden()
read_cache = True
#if query is in the cache, the expire flag is true, and the access
#time is old, set read_cache = False
if cache.get(iden) is not None:
if cache.get(expire_key(sr)):
access_time = cache.get(access_key(sr))
if not access_time or datetime.now() > access_time + expire_delta:
cache.delete(expire_key(sr))
read_cache = False
#if the query isn't in the cache, set read_cache to false so we
#record the access time
else:
read_cache = False
#set access time to the last time the query was actually run (now)
if not read_cache:
cache.set(access_key(sr), datetime.now())
query._read_cache = read_cache
res = list(query)
return res
示例2: get_hot
def get_hot(sr):
q = Link._query(Link.c.sr_id == sr._id,
sort = desc('_hot'),
write_cache = True,
limit = 150)
iden = q._iden()
read_cache = True
#if query is in the cache, the expire flag is true, and the access
#time is old, set read_cache = False
if cache.get(iden) is not None:
if cache.get(expire_key(sr)):
access_time = cache.get(access_key(sr))
if not access_time or datetime.now() > access_time + expire_delta:
cache.delete(expire_key(sr))
read_cache = False
#if the query isn't in the cache, set read_cache to false so we
#record the access time
else:
read_cache = False
if not read_cache:
cache.set(access_key(sr), datetime.now())
q._read_cache = read_cache
res = list(q)
#set the #1 link so we can ignore it later. expire after TOP_CACHE
#just in case something happens and that sr doesn't update
if res:
cache.set(top_key(sr), res[0]._fullname, TOP_CACHE)
return res
示例3: _other_self
def _other_self(self):
"""Load from the cached version of myself. Skip the local cache."""
l = cache.get(self._cache_key(), allow_local=False)
if l and l._id != self._id:
g.log.error("thing.py: Doppleganger on read: got %s for %s", (l, self))
cache.delete(self._cache_key())
return
return l
示例4: _delete_from_db
def _delete_from_db(self):
"""
Usually Things are soft-deleted, so this should be called rarely, and
only in cases where you're sure the Thing isn't referenced anywhere else.
"""
if not self._created:
return
tdb.del_thing(self._type_id, self._id)
cache.delete(thing_prefix(self.__class__.__name__, self._id))
示例5: POST_resetpassword
def POST_resetpassword(self, res, uid, key, password):
res._update('status', innerHTML = '')
if res._chk_error(errors.BAD_PASSWORD):
res._focus('passwd')
elif res._chk_error(errors.BAD_PASSWORD_MATCH):
res._focus('passwd2')
else:
user = Account._byID(uid, data=True)
change_password(user, user.password, password)
cache.delete(str('reset_%s' % key))
self._login(res, user, '/resetpassword')
示例6: _delete
def _delete(self):
tdb.del_rel(self._type_id, self._id)
#clear cache
prefix = thing_prefix(self.__class__.__name__)
#TODO - there should be just one cache key for a rel?
cache.delete(prefix + str(self._id))
#update fast query cache
cache.set(prefix + str((self._thing1_id,
self._thing2_id,
self._name)), None)
示例7: valid_solution
def valid_solution(iden, solution):
if (not iden
or not solution
or len(iden) != IDEN_LENGTH
or len(solution) != SOL_LENGTH
or solution.upper() != cache.get(str(iden))):
solution = make_solution()
cache.set(str(iden), solution, time = 300)
return False
else:
cache.delete(str(iden))
return True
示例8: _delete
def _delete(self):
tdb.del_rel(self._type_id, self._id)
# clear cache
prefix = thing_prefix(self.__class__.__name__)
# TODO - there should be just one cache key for a rel?
cache.delete(prefix + str(self._id))
# update fast query cache
cache.set(prefix + str((self._thing1_id, self._thing2_id, self._name)), None)
# temporarily set this property so the rest of this request
# know it's deleted. save -> unsave, hide -> unhide
self._name = "un" + self._name
示例9: _uncache
def _uncache(cls, thing1, thing2, name):
# Remove a rel from from the fast query cache
prefix = thing_prefix(cls.__name__)
cache.delete(prefix + str((thing1._id,
thing2._id,
name)))
示例10: clear_memo
def clear_memo(iden, *a, **kw):
key = iden + str(a) + str(kw)
#print 'CLEARING', key
cache.delete(key)
示例11: clear_memo
def clear_memo(iden, *a, **kw):
from r2.config import cache
key = iden + str(a) + str(kw)
# print 'CLEARING', key
cache.delete(key)
示例12: clear_memo
def clear_memo(iden, *a, **kw):
key = _make_key(iden, a, kw)
#print 'CLEARING', key
cache.delete(key)