another attempt at memcache

This commit is contained in:
mdipierro
2012-08-15 17:24:25 -05:00
parent 64af8ae88f
commit aacfdb62bb
2 changed files with 11 additions and 3 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.00.0 (2012-08-15 17:18:21) dev Version 2.00.0 (2012-08-15 17:24:22) dev
+10 -2
View File
@@ -59,7 +59,9 @@ class MemcacheClientObj(Client):
else: else:
item = self.get(key) item = self.get(key)
if item: if item:
if (item[0] < now - dt): # value expired if not isinstance(item,(list,tuple)):
value = item
elif (item[0] < now - dt): # value expired
item = None # value to be computed item = None # value to be computed
else: else:
value = item[1] value = item[1]
@@ -73,7 +75,13 @@ class MemcacheClientObj(Client):
newKey = self.__keyFormat__(key) newKey = self.__keyFormat__(key)
obj = Client.get(self, newKey) obj = Client.get(self, newKey)
if obj: if obj:
return Client.incr(self, newKey, value) 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: else:
Client.set(self, newKey, value, self.max_time_expire) Client.set(self, newKey, value, self.max_time_expire)
return value return value