def getUserInfoById(uid): uid = long(uid) uid_tmp = str(uid) info = RedisHandler.f_hget(USERINFO, uid_tmp) if info: raise gen.Return(json.loads(info)) else: user = yield motorclient.fbt_realtime.users.find_one({"uid": uid}, {"_id": 0}) if user: cacheUserInfo(user) gender = user["gender"] if gender: if gender == u"男": gender = 1 else: gender = 0 info = { "nick_name": user["nick_name"], "icon": user["icon"], "user": user["user"], "gender": gender, "school": user["school"] } raise gen.Return(info) else: raise gen.Return(None)
def getUserByNick(nick_name): user = RedisHandler.f_hget(NICKINFO, nick_name) if user: raise gen.Return(user) else: user = yield motorclient.fbt_realtime.users.find_one({"nick_name": nick_name}, {"_id": 0, "user": 1}) if user: RedisHandler.f_hset(NICKINFO, nick_name, user["user"]) raise gen.Return(user["user"]) else: raise gen.Return(None)
def getFriendsById(uid): uid = long(uid) uid_tmp = str(uid) info = RedisHandler.f_hget(FRIENDINFO, uid_tmp) if info: raise gen.Return(json.loads(info)) else: user = yield motorclient.fbt_realtime.users.find_one({"uid": uid}, {"_id": 0, "friends": 1}) if user: RedisHandler.f_hset(FRIENDINFO, uid_tmp, json.dumps(user["friends"])) raise gen.Return(user["friends"]) else: raise gen.Return(None)
def getUserByNick(nick_name): user = RedisHandler.f_hget(NICKINFO, nick_name) if user: raise gen.Return(user) else: user = yield motorclient.fbt_realtime.users.find_one( {"nick_name": nick_name}, { "_id": 0, "user": 1 }) if user: RedisHandler.f_hset(NICKINFO, nick_name, user["user"]) raise gen.Return(user["user"]) else: raise gen.Return(None)
def getFriendsById(uid): uid = long(uid) uid_tmp = str(uid) info = RedisHandler.f_hget(FRIENDINFO, uid_tmp) if info: raise gen.Return(json.loads(info)) else: user = yield motorclient.fbt_realtime.users.find_one({"uid": uid}, { "_id": 0, "friends": 1 }) if user: RedisHandler.f_hset(FRIENDINFO, uid_tmp, json.dumps(user["friends"])) raise gen.Return(user["friends"]) else: raise gen.Return(None)
def getUserInfoById(uid): uid = long(uid) uid_tmp = str(uid) info = RedisHandler.f_hget(USERINFO, uid_tmp) if info: raise gen.Return(json.loads(info)) else: user = yield motorclient.fbt_realtime.users.find_one({"uid": uid}, {"_id": 0}) if user: cacheUserInfo(user) gender = user["gender"] if gender: if gender == u"男": gender = 1 else: gender = 0 info = {"nick_name": user["nick_name"], "icon": user["icon"], "user": user["user"], "gender": gender, "school": user["school"]} raise gen.Return(info) else: raise gen.Return(None)