def updateFriendsById(uid): uid = long(uid) uid_tmp = str(uid) 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"]))
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 cacheUserInfo(user): uid_tmp = str(user["uid"]) gender = user["gender"] if gender: if gender == u"男": gender = 1 else: gender = 0 info = json.dumps({"nick_name": user["nick_name"], "icon": user["icon"], "user": user["user"], "gender": gender, "school": user["school"]}) RedisHandler.f_hset(FRIENDINFO, uid_tmp, json.dumps(user["friends"])) RedisHandler.f_hset(USERINFO, uid_tmp, info)
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 cacheUserInfo(user): uid_tmp = str(user["uid"]) gender = user["gender"] if gender: if gender == u"男": gender = 1 else: gender = 0 info = json.dumps({ "nick_name": user["nick_name"], "icon": user["icon"], "user": user["user"], "gender": gender, "school": user["school"] }) RedisHandler.f_hset(FRIENDINFO, uid_tmp, json.dumps(user["friends"])) RedisHandler.f_hset(USERINFO, uid_tmp, info)
def updateFriendsById(uid): uid = long(uid) uid_tmp = str(uid) 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"]))