Commit f3602d5c authored by 段英荣's avatar 段英荣

modify

parent 1d6a9cfb
......@@ -27,6 +27,13 @@ def home_recommend(session_id="",user_id=-1,offset=0,size=10):
if not isinstance(session_id,str):
session_id = ""
redis_key = "physical:home_recommend" + ":user_id:" + str(user_id) + ":session_id:" + session_id
redis_field_list = [b'last_offset_num', b'unread_topic_id', b'have_read_topic_id']
for page_id in range(0,offset,size):
redis_field_list.append(str(page_id))
redis_field_val_list = redis_client.hmget(redis_key,redis_field_list)
logging.info("duan add,redis_field_list:%s,redis_field_val_list:%s" % (str(redis_field_list),str(redis_field_val_list)))
redis_val_dict = redis_client.hgetall(redis_key)
last_offset_num = int(redis_val_dict[b"last_offset_num"]) if b"last_offset_num" in redis_val_dict else -1
......@@ -79,7 +86,8 @@ def home_recommend(session_id="",user_id=-1,offset=0,size=10):
redis_dict = {
"unread_topic_id":json.dumps(unread_topic_id_list),
"have_read_topic_id":redis_have_redis_data,
"last_offset_num":offset+size
"last_offset_num":offset+size,
offset:recommend_topic_ids
}
redis_client.hmset(redis_key,redis_dict)
# 每个session key保存15分钟
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment