-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogressCache.py
36 lines (27 loc) · 890 Bytes
/
progressCache.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from google.appengine.api import memcache
class ProgressCache(object):
@staticmethod
def __getKey(userID, prop):
return '%s__%s' % (userID, prop)
@staticmethod
def set(userID, prop, value):
# return
memcache.set(ProgressCache.__getKey(userID, prop), value)
@staticmethod
def get(userID, prop):
return memcache.get(ProgressCache.__getKey(userID, prop))
@staticmethod
def getMulti(userID, props):
keys = []
for prop in props:
keys.append(ProgressCache.__getKey(userID, prop))
return memcache.get_multi(keys)
@staticmethod
def setMulti(userID, dict):
newDict = {}
for key, value in dict.items():
newDict[ProgressCache.__getKey(userID, key)] = value
memcache.set_multi(newDict)
@staticmethod
def flush():
memcache.flush_all()