本文整理汇总了Python中gluon.contrib.memcache.memcache.Client.set方法的典型用法代码示例。如果您正苦于以下问题:Python Client.set方法的具体用法?Python Client.set怎么用?Python Client.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gluon.contrib.memcache.memcache.Client
的用法示例。
在下文中一共展示了Client.set方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: increment
# 需要导入模块: from gluon.contrib.memcache.memcache import Client [as 别名]
# 或者: from gluon.contrib.memcache.memcache.Client import set [as 别名]
def increment(self, key, value=1, time_expire=300):
newKey = self.__keyFormat__(key)
obj = Client.get(self, newKey)
if obj:
return Client.incr(self, newKey, value)
else:
Client.set(self, newKey, value, time_expire)
return value
示例2: increment
# 需要导入模块: from gluon.contrib.memcache.memcache import Client [as 别名]
# 或者: from gluon.contrib.memcache.memcache.Client import set [as 别名]
def increment(self, key, value=1, time_expire=DEFAULT_TIME_EXPIRE):
""" time_expire is ignored """
newKey = self.__keyFormat__(key)
obj = Client.get(self, newKey)
if obj:
if isinstance(obj,(int,double,long)):
return Client.incr(self, newKey, value)
else:
value += obj[1]
Client.set(self,newKey,(time.time(),value),
self.max_time_expire)
return value
else:
Client.set(self, newKey, value, self.max_time_expire)
return value
示例3: increment
# 需要导入模块: from gluon.contrib.memcache.memcache import Client [as 别名]
# 或者: from gluon.contrib.memcache.memcache.Client import set [as 别名]
def increment(self, key, value=1, time_expire='default'):
""" time_expire is ignored """
if time_expire == 'default':
time_expire = self.default_time_expire
newKey = self.__keyFormat__(key)
obj = Client.get(self, newKey)
if obj:
if isinstance(obj,(int,float,long)):
return Client.incr(self, newKey, value)
else:
value += obj[1]
Client.set(self,newKey,(time.time(),value),
self.max_time_expire)
return value
else:
Client.set(self, newKey, value, self.max_time_expire)
return value
示例4: set
# 需要导入模块: from gluon.contrib.memcache.memcache import Client [as 别名]
# 或者: from gluon.contrib.memcache.memcache.Client import set [as 别名]
def set(self,key,value,time_expire=300):
newKey = self.__keyFormat__(key)
return Client.set(self,newKey,value,time_expire)
示例5: set
# 需要导入模块: from gluon.contrib.memcache.memcache import Client [as 别名]
# 或者: from gluon.contrib.memcache.memcache.Client import set [as 别名]
def set(self, key, value, time_expire=DEFAULT_TIME_EXPIRE):
newKey = self.__keyFormat__(key)
return Client.set(self, newKey, value, time_expire)
示例6: set
# 需要导入模块: from gluon.contrib.memcache.memcache import Client [as 别名]
# 或者: from gluon.contrib.memcache.memcache.Client import set [as 别名]
def set(self, key, value, time_expire='default'):
if time_expire == 'default':
time_expire = self.default_time_expire
newKey = self.__keyFormat__(key)
return Client.set(self, newKey, value, time_expire)