本文整理汇总了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)