本文整理匯總了Python中google.appengine.api.memcache.Client方法的典型用法代碼示例。如果您正苦於以下問題:Python memcache.Client方法的具體用法?Python memcache.Client怎麽用?Python memcache.Client使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類google.appengine.api.memcache
的用法示例。
在下文中一共展示了memcache.Client方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: import_preferred_memcache_lib
# 需要導入模塊: from google.appengine.api import memcache [as 別名]
# 或者: from google.appengine.api.memcache import Client [as 別名]
def import_preferred_memcache_lib(self, servers):
"""Returns an initialized memcache client. Used by the constructor."""
try:
import pylibmc
except ImportError:
pass
else:
return pylibmc.Client(servers)
try:
from google.appengine.api import memcache
except ImportError:
pass
else:
return memcache.Client()
try:
import memcache
except ImportError:
pass
else:
return memcache.Client(servers)
# backwards compatibility
示例2: import_preferred_memcache_lib
# 需要導入模塊: from google.appengine.api import memcache [as 別名]
# 或者: from google.appengine.api.memcache import Client [as 別名]
def import_preferred_memcache_lib(self, servers):
"""Returns an initialized memcache client. Used by the constructor."""
try:
import pylibmc
except ImportError:
pass
else:
return pylibmc.Client(servers)
try:
from google.appengine.api import memcache
except ImportError:
pass
else:
return memcache.Client()
try:
import memcache
except ImportError:
pass
else:
return memcache.Client(servers)
try:
import libmc
except ImportError:
pass
else:
return libmc.Client(servers)
# backwards compatibility
示例3: _GetXsrfKey
# 需要導入模塊: from google.appengine.api import memcache [as 別名]
# 或者: from google.appengine.api.memcache import Client [as 別名]
def _GetXsrfKey():
"""Returns the current key for generating and verifying XSRF tokens."""
client = memcache.Client()
xsrf_key = client.get('xsrf_key')
if not xsrf_key:
config = models.GetApplicationConfiguration()
xsrf_key = config.xsrf_key
client.set('xsrf_key', xsrf_key)
return xsrf_key
示例4: bump_counter
# 需要導入模塊: from google.appengine.api import memcache [as 別名]
# 或者: from google.appengine.api.memcache import Client [as 別名]
def bump_counter(key, time=3600, limit=4):
client = memcache.Client()
for _ in range(limit):
counter = client.gets(key)
if counter is None:
client.set(key, 0, time=time)
counter = 0
if client.cas(key, counter + 1):
break
###############################################################################
# Auth Attempts stuff
###############################################################################
示例5: reset_auth_attempt
# 需要導入模塊: from google.appengine.api import memcache [as 別名]
# 或者: from google.appengine.api.memcache import Client [as 別名]
def reset_auth_attempt():
client = memcache.Client()
client.set(get_auth_attempt_key(), 0, time=3600)
示例6: get_auth_attempt
# 需要導入模塊: from google.appengine.api import memcache [as 別名]
# 或者: from google.appengine.api.memcache import Client [as 別名]
def get_auth_attempt():
client = memcache.Client()
return client.get(get_auth_attempt_key()) or 0
示例7: import_preferred_memcache_lib
# 需要導入模塊: from google.appengine.api import memcache [as 別名]
# 或者: from google.appengine.api.memcache import Client [as 別名]
def import_preferred_memcache_lib(self, servers):
"""Returns an initialized memcache client. Used by the constructor."""
try:
import pylibmc
except ImportError:
pass
else:
return pylibmc.Client(servers)
try:
from google.appengine.api import memcache
except ImportError:
pass
else:
return memcache.Client()
try:
import memcache
except ImportError:
pass
else:
return memcache.Client(servers)
try:
import libmc
except ImportError:
pass
else:
return libmc.Client(servers)