def _setSessionDatas(userId, datas): # TODO 补充user表中的几个数据至用户的session中sessionAppId, sessionDevId,city_code atts = [ UserDataSchema.SESSION_APPID, UserDataSchema.SESSION_DEVID, UserDataSchema.SESSION_CITY_CODE, UserDataSchema.SESSION_IP ] values = daobase.executeUserCmd(userId, 'HMGET', UserDataSchema.mkey(userId), *atts) values = UserDataSchema.checkDataList(atts, values, None) if not UserSessionSchema.APPID in datas: datas[UserSessionSchema.APPID] = values[0] if not UserSessionSchema.DEVICEID in datas: datas[UserSessionSchema.DEVICEID] = values[1] if not UserSessionSchema.CITYCODE in datas: datas[UserSessionSchema.CITYCODE] = values[2] datas[UserSessionSchema.IPADDRESS] = values[ 3] # TODO 加了阿里云代理后,CO服务的带的IP都是阿里的IP地址,只能在重SDK的数据中再取一次 dataKey = UserSessionSchema.mkey(userId) params = UserSessionSchema.paramsDict2List(datas) ret = daobase.sendUserCmd(userId, 'HMSET', dataKey, *params) return ret
def _getUserDatas(userId, fieldList): dataKey = UserDataSchema.mkey(userId) values = daobase.executeUserCmd(userId, 'HMGET', dataKey, *fieldList) values = UserDataSchema.checkDataList(fieldList, values, None) ftlog.debug('_getUserDatas->', userId, fieldList, values) return values