Esempio n. 1
0
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"]))
Esempio n. 2
0
File: util.py Progetto: BoneLee/FBT
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)
Esempio n. 3
0
File: util.py Progetto: BoneLee/FBT
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)
Esempio n. 4
0
File: util.py Progetto: BoneLee/FBT
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)
Esempio n. 5
0
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)
Esempio n. 6
0
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)
Esempio n. 7
0
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)
Esempio n. 8
0
File: util.py Progetto: BoneLee/FBT
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"]))