def set_daily_data(self, gid, *args, **kwargs): l = Tool.dict2list(kwargs) l.extend(args) if len(l) % 2 != 0: raise Exception('error param') key = '%s:%s:%s' % (self.prefix, gid, Time.current_time(self.format)) return self.ctx.RedisStat.hash_mset(key, *l)
def __make_arg_list(self, *args, **kwargs): l = list(args) if kwargs: _ = Tool.dict2list(kwargs) l.extend(_) if len(l) < 2 or len(l) % 2 != 0: raise Exception('error count') for i in xrange(0, len(l), 2): try: int(l[i + 1]) except Exception, e: raise Exception('error param %s' % l)
def set_daily_data(self, uid, gid, *args, **kwargs): l = Tool.dict2list(kwargs) l.extend(args) if len(l) % 2 != 0: raise Exception('error param') key = 'daily:%d:%d' % (gid, uid) tomorrow_ts = Time.tomorrow_start_ts() isNew = self.ctx.RedisCluster.hash_setnx(uid, key, 'expire_ts', tomorrow_ts) if isNew: self.ctx.RedisCluster.hash_mset(uid, key, *l) self.ctx.RedisCluster.expire_at(uid, key, tomorrow_ts) else: self.ctx.RedisCluster.hash_mset(uid, key, *l)