Commit e4292ba8 authored by 郭羽's avatar 郭羽

画像压缩测试

parent cd857f64
import datetime
import functools
import json
import zlib
import operator
from collections import Counter
......@@ -294,7 +295,8 @@ def update_tag3_user_portrait(cl_id):
# if tmp_res:
# res.update(tmp_res)
key = "doris:user_portrait:tag3:device_id:" + str(cl_id)
key = "doris:user_portrait:device_id:" + str(cl_id)
# key = "doris:user_portrait:tag3:device_id:" + str(cl_id)
redis_client = get_redis_client()
user_portrait_raw = get_user_portrait_tag3_with_score(cl_id)
......@@ -314,22 +316,24 @@ def update_tag3_user_portrait(cl_id):
(len(first_positions_score.keys()) > 0) or (len(second_positions_score.keys()) > 0) or \
(len(projects_score.keys()) > 0) or (len(business_tags_score.keys()) > 0) or \
(len(selected_stars_score.keys()) > 0) or (len(selected_internet_celebrity_score.keys()) > 0):
redis_client.set(key, json.dumps(res))
redis_client.expire(key, 60 * 60 * 24 * 180)
write_user_portrait(
cl_id,
",".join(first_solutions_score.keys()),
",".join(second_solutions_score.keys()),
",".join(first_demands_score.keys()),
",".join(second_demands_score.keys()),
",".join(first_positions_score.keys()),
",".join(second_positions_score.keys()),
",".join(projects_score.keys()),
",".join(business_tags_score.keys()),
",".join(selected_stars_score.keys()),
",".join(selected_internet_celebrity_score.keys()),
)
json_str = json.dumps(res)
zlib_res = zlib.compress(bytes(json_str,encoding='utf-8'))
redis_client.set(key, zlib_res)
redis_client.expire(key, 60 * 60 * 24 * 90)
# write_user_portrait(
# cl_id,
# ",".join(first_solutions_score.keys()),
# ",".join(second_solutions_score.keys()),
# ",".join(first_demands_score.keys()),
# ",".join(second_demands_score.keys()),
# ",".join(first_positions_score.keys()),
# ",".join(second_positions_score.keys()),
# ",".join(projects_score.keys()),
# ",".join(business_tags_score.keys()),
# ",".join(selected_stars_score.keys()),
# ",".join(selected_internet_celebrity_score.keys()),
# )
# body = {}
# for (k, v) in res.items():
......
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