示例#1
0
文件: mc_total.py 项目: pakt/sqlbean
 def __call__(self, key):
     mk = self.mc_key%key
     count = mc.get(mk)
     if count is None:
         count = self.get_count(key) or 0
         mc.set(mk, count, self.timeout)
     return count
示例#2
0
文件: mc_total.py 项目: pakt/sqlbean
 def get_multi(self, keys):
     mc_key = self.mc_key
     mc_key_list = dict([(key, mc_key%key) for key in keys])
     result = mc.get_multi(mc_key_list.itervalues())
     r = {}
     for k, mck in mc_key_list.iteritems():
         v = result.get(mck)
         if v is None:
             v = self.get_count(k) or 0
             mc.set(mck, v)
         r[k] = v
     return r