Example #1
0
 def mc_get_dict(cls, id_list):
     if type(id_list) not in (array, list, tuple, dict):
         id_list = tuple(id_list)
     mc_key = cls.__key__
     result = mc.get_dict_msgpack([mc_key%i for i in id_list], cls._loads)
     r = {}
     for i in id_list:
         t = result.get(mc_key%i)
         if t is None:
             if i:
                 t = cls.get(i)
                 if t:
                     t.mc_set()
         r[i] = t
     return r
Example #2
0
 def mc_get_dict(cls, id_list):
     if type(id_list) not in (array, list, tuple, dict):
         id_list = tuple(id_list)
     mc_key = cls.__key__
     result = mc.get_dict_msgpack([mc_key % i for i in id_list], cls._loads)
     r = {}
     for i in id_list:
         t = result.get(mc_key % i)
         if t is None:
             if i:
                 t = cls.get(i)
                 if t:
                     t.mc_set()
         r[i] = t
     return r
Example #3
0
 def mc_get_list(cls, id_list):
     if type(id_list) not in (array, list, tuple, dict):
         id_list = tuple(id_list)
     mc_key = cls.__key__
     result = mc.get_dict_msgpack([mc_key%i for i in id_list], cls._loads)
     r = []
     for i in id_list:
         t = result.get(mc_key%i)
         if t is None:
             if i:
                 t = cls.get(i)
                 if t:
                     t.mc_set()
                 else:
                     import logging
                     logging.error("mc_get_list 无效用户id:%s" % i)
                     continue
         r.append(t)
     return r
Example #4
0
 def mc_get_list(cls, id_list):
     if type(id_list) not in (array, list, tuple, dict):
         id_list = tuple(id_list)
     mc_key = cls.__key__
     result = mc.get_dict_msgpack([mc_key % i for i in id_list], cls._loads)
     r = []
     for i in id_list:
         t = result.get(mc_key % i)
         if t is None:
             if i:
                 t = cls.get(i)
                 if t:
                     t.mc_set()
                 else:
                     import logging
                     logging.error("mc_get_list 无效用户id:%s" % i)
                     continue
         r.append(t)
     return r