def rec_read_user_topic_score_incr(user_id, tag_id, score=1, tag_score=None): key = REDIS_REC_USER_TAG%user_id if score == inf: score_list = redis.zrevrange(key, 0, 0, True, int) if score_list: score = max(1, score_list[0][1]) else: score = 1 redis.zadd(key, tag_id, score) elif score == ninf: redis.zrem(key, tag_id) else: redis.zincrby(key, tag_id, score) if tag_score is None: tag_score = score redis.zincrby(REDIS_REC_TAG, tag_id, tag_score) # zrank < REDIS_REC_USER_TAG_LIMIT的时候 # 并且不在读完的redis时候 , 进入候选的推荐主题 if redis.zrevrank(key, tag_id) < REDIS_REC_USER_TAG_LIMIT : if not redis.sismember(REDIS_REC_TAG_USER_IS_EMPTY%tag_id, user_id): _rec_topic_new_by_user_id_topic_id_score(user_id, tag_id)
def is_spammer(user_id): return redis.sismember(SPAMMER_REDIS_KEY, user_id)