fix cache.increment, added tests

This commit is contained in:
niphlod
2014-09-16 23:50:10 +02:00
parent 424746ce7a
commit 50f16744a7
4 changed files with 53 additions and 5 deletions
+9 -3
View File
@@ -357,7 +357,7 @@ class CacheOnDisk(CacheAbstract):
os.mkdir(folder)
self.storage = CacheOnDisk.PersistentStorage(folder)
if not CacheAbstract.cache_stats_name in self.storage:
self.storage[CacheAbstract.cache_stats_name] = {'hit_total': 0, 'misses': 0}
@@ -402,7 +402,13 @@ class CacheOnDisk(CacheAbstract):
def increment(self, key, value=1):
self.initialize()
self.storage[key] += value
storage = self.storage
try:
if key in storage:
value = storage[key][1] + value
storage[key] = (time.time(), value)
except:
pass
return value
@@ -445,7 +451,7 @@ class Cache(object):
def __init__(self, request):
"""
Args:
Args:
request: the global request object
"""
# GAE will have a special caching