本文整理汇总了Python中google.appengine.api.memcache.delete方法的典型用法代码示例。如果您正苦于以下问题:Python memcache.delete方法的具体用法?Python memcache.delete怎么用?Python memcache.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类google.appengine.api.memcache
的用法示例。
在下文中一共展示了memcache.delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ClearDatastore
# 需要导入模块: from google.appengine.api import memcache [as 别名]
# 或者: from google.appengine.api.memcache import delete [as 别名]
def ClearDatastore(request):
"""Clears data in the datastore, many at a time (for admins only)."""
clear = (None, 'None')
atatime = 10
msg = ''
query = db.Query(clear[0])
rows = query.fetch(atatime)
length = len(rows)
if length is 0:
msg += 'No more rows to delete<br>'
else:
msg += 'Deleting %s %s<br>' % (length, clear[1])
db.delete(rows)
query = db.Query(clear[0])
more = query.fetch(1)
if len(more) is not 0:
msg += 'Now do it again!'
msg += '<script>window.location.href="/reflows/clear_datastore";</script>'
return http.HttpResponse(msg)
示例2: post
# 需要导入模块: from google.appengine.api import memcache [as 别名]
# 或者: from google.appengine.api.memcache import delete [as 别名]
def post(self):
# We set the same parent key on the 'Greeting' to ensure each greeting
# is in the same entity group. Queries across the single entity group
# are strongly consistent. However, the write rate to a single entity
# group is limited to ~1/second.
guestbook_name = self.request.get('guestbook_name')
greeting = Greeting(parent=guestbook_key(guestbook_name))
if users.get_current_user():
greeting.author = users.get_current_user().nickname()
greeting.content = self.request.get('content')
greeting.put()
memcache.delete('{}:greetings'.format(guestbook_name))
self.redirect('/?' +
urllib.urlencode({'guestbook_name': guestbook_name}))
示例3: end_recording
# 需要导入模块: from google.appengine.api import memcache [as 别名]
# 或者: from google.appengine.api.memcache import delete [as 别名]
def end_recording(status, firepython_set_extension_data=None):
"""Stop recording RPC traces and save all traces to memcache.
This clears the recorder set for this request in 'recorder_proxy'.
Args:
status: HTTP Status, a 3-digit integer.
"""
if firepython_set_extension_data is not None:
warnings.warn('Firepython is no longer supported')
rec = recorder_proxy.get_for_current_request()
recorder_proxy.clear_for_current_request()
if config.DEBUG:
logging.debug('Cleared recorder')
if rec is not None:
try:
rec.record_http_status(status)
rec.save()
finally:
memcache.delete(lock_key(), namespace=config.KEY_NAMESPACE)
示例4: post
# 需要导入模块: from google.appengine.api import memcache [as 别名]
# 或者: from google.appengine.api.memcache import delete [as 别名]
def post(self):
"""Handle POST."""
index_name = self.request.get('index')
namespace = self.request.get('namespace')
docs = []
index = 0
num_docs = int(self.request.get('numdocs'))
for i in xrange(1, num_docs+1):
key = self.request.get('doc%d' % i)
if key:
docs.append(key)
index = search.Index(name=index_name, namespace=namespace)
index.delete(docs)
self.redirect(self.request.get('next'))
示例5: __init__
# 需要导入模块: from google.appengine.api import memcache [as 别名]
# 或者: from google.appengine.api.memcache import delete [as 别名]
def __init__(self):
# Check if any tasks need to be run
query = _AppEngineUtilities_Cron.all()
query.filter('next_run <= ', datetime.datetime.now())
results = query.fetch(1000)
if len(results) > 0:
one_second = datetime.timedelta(seconds = 1)
before = datetime.datetime.now()
for r in results:
if re.search(':' + APPLICATION_PORT, r.url):
r.url = re.sub(':' + APPLICATION_PORT, ':' + CRON_PORT, r.url)
#result = urlfetch.fetch(r.url)
diff = datetime.datetime.now() - before
if int(diff.seconds) < 1:
if memcache.add(str(r.key), "running"):
result = urlfetch.fetch(r.url)
r.next_run = self._get_next_run(pickle.loads(r.cron_compiled))
r.put()
memcache.delete(str(r.key))
else:
break
示例6: get_items
# 需要导入模块: from google.appengine.api import memcache [as 别名]
# 或者: from google.appengine.api.memcache import delete [as 别名]
def get_items(self):
"""
Returns all the items stored in a session
"""
items = memcache.get("_AppEngineUtilities_SessionData_" + str(self.session_key))
if items:
for item in items:
if item.deleted == True:
item.delete()
items.remove(item)
return items
query = _AppEngineUtilities_SessionData.all()
query.filter('session_key', self.session_key)
results = query.fetch(1000)
return results
示例7: get_item
# 需要导入模块: from google.appengine.api import memcache [as 别名]
# 或者: from google.appengine.api.memcache import delete [as 别名]
def get_item(self, keyname = None):
"""
Returns a single item from the memcache or datastore
"""
mc = memcache.get("_AppEngineUtilities_SessionData_" + str(self.session_key))
if mc:
for item in mc:
if item.keyname == keyname:
if item.deleted == True:
item.delete()
return None
return item
query = _AppEngineUtilities_SessionData.all()
query.filter("session_key = ", self.session_key)
query.filter("keyname = ", keyname)
results = query.fetch(1)
if len(results) > 0:
memcache.set("_AppEngineUtilities_SessionData_" + str(self.session_key), self.get_items_ds())
return results[0]
return None
示例8: delete_all_sessions
# 需要导入模块: from google.appengine.api import memcache [as 别名]
# 或者: from google.appengine.api.memcache import delete [as 别名]
def delete_all_sessions(cls):
"""
Deletes all sessions and session data from the data store and memcache:
NOTE: This is not fully developed. It also will not delete any cookie
data as this does not work for each incoming request. Keep this in mind
if you are using the cookie writer.
"""
all_sessions_deleted = False
all_data_deleted = False
while not all_sessions_deleted:
query = _AppEngineUtilities_Session.all()
results = query.fetch(75)
if len(results) is 0:
all_sessions_deleted = True
else:
for result in results:
result.delete()
示例9: _clean_old_sessions
# 需要导入模块: from google.appengine.api import memcache [as 别名]
# 或者: from google.appengine.api.memcache import delete [as 别名]
def _clean_old_sessions(self):
"""
Delete expired sessions from the datastore.
This is only called for CLEAN_CHECK_PERCENT percent of requests because
it could be rather intensive.
"""
duration = datetime.timedelta(seconds=self.session_expire_time)
session_age = datetime.datetime.now() - duration
query = _AppEngineUtilities_Session.all()
query.filter('last_activity <', session_age)
results = query.fetch(50)
for result in results:
"""
OLD
data_query = _AppEngineUtilities_SessionData.all()
data_query.filter('session', result)
data_results = data_query.fetch(1000)
for data_result in data_results:
data_result.delete()
memcache.delete('sid-'+str(result.key()))
"""
result.delete()
# Implement Python container methods
示例10: __delitem__
# 需要导入模块: from google.appengine.api import memcache [as 别名]
# 或者: from google.appengine.api.memcache import delete [as 别名]
def __delitem__(self, keyname):
"""
Delete item from session data.
Args:
keyname: The keyname of the object to delete.
"""
bad_key = False
sessdata = self._get(keyname = keyname)
if sessdata is None:
bad_key = True
else:
sessdata.delete()
if keyname in self.cookie_vals:
del self.cookie_vals[keyname]
bad_key = False
self.output_cookie[self.cookie_name + '_data'] = \
simplejson.dumps(self.cookie_vals)
print self.output_cookie.output()
if bad_key:
raise KeyError(str(keyname))
if keyname in self.cache:
del self.cache[keyname]
示例11: add_memcache
# 需要导入模块: from google.appengine.api import memcache [as 别名]
# 或者: from google.appengine.api.memcache import delete [as 别名]
def add_memcache(self, test):
memcache_keyname = self.get_memcache_keyname(test)
memcache.delete(memcache_keyname)
memcache.add(memcache_keyname, self,
settings.STATS_USERTEST_TIMEOUT)
示例12: delete_memcache
# 需要导入模块: from google.appengine.api import memcache [as 别名]
# 或者: from google.appengine.api.memcache import delete [as 别名]
def delete_memcache(self):
memcache.delete(self.get_memcache_keyname())
示例13: DeleteMemcacheValue
# 需要导入模块: from google.appengine.api import memcache [as 别名]
# 或者: from google.appengine.api.memcache import delete [as 别名]
def DeleteMemcacheValue(cls, category, version_level):
key_name = cls.KeyName(category, version_level)
memcache.delete(key_name, namespace=cls.MEMCACHE_NAMESPACE)
示例14: ClearShardedCounterTotal
# 需要导入模块: from google.appengine.api import memcache [as 别名]
# 或者: from google.appengine.api.memcache import delete [as 别名]
def ClearShardedCounterTotal(name):
memcache.delete(_COUNTER_TOTAL.format(name))
示例15: delete
# 需要导入模块: from google.appengine.api import memcache [as 别名]
# 或者: from google.appengine.api.memcache import delete [as 别名]
def delete(key=None):
parts_count = memcache.get(key='%s_parts' % key)
if parts_count:
for i in xrange(parts_count):
memcache.delete(key='%s%d' % (key, i))
memcache.delete(key=key)
memcache.delete(key='%s_parts' % key)