Commit 0d8d6228 by 岳巧源

add redis hset

parent c4c0d8d1
Showing with 16 additions and 2 deletions
......@@ -20,7 +20,9 @@ config_dev = {
"database": "liexin_data_distribution"
},
"redis": {
"host": "192.168.1.235",
"port": 6379,
"password": "icDb29mLy2s"
}
}
......@@ -154,8 +156,10 @@ def update_ext_attr_by_class_ids(conf: dict):
token = "845ce8478b074103b9e78a769d5fa4831y2u"
app_key = "CA52430E90209F51D8F5D7B615DDE9AD"
app_secret = "c92691b2379c48de87e699c4c2f7fb32"
class_attr_mapping = {}
for i in range(len(class_ids)):
class_id = class_ids[i]
class_attr_mapping[class_id] = []
param = {
"category_leaf_id": class_id,
}
......@@ -214,7 +218,7 @@ def update_ext_attr_by_class_ids(conf: dict):
def insert_ext_attr_to_redis(class_attr_map: dict):
def insert_ext_attr_to_redis(class_attr_map: dict, conf: dict):
"""
拓展属性存到 redis中
key : jd_ext_attr
......@@ -228,6 +232,16 @@ def insert_ext_attr_to_redis(class_attr_map: dict):
33471: [1001074361, 236705]
}
"""
host = conf["redis"]["host"]
port = conf["redis"]["port"]
password = conf["redis"]["password"]
db = redis.Redis(host=host, port=port, password=password, decode_responses=True)
for class_id in class_attr_map:
key = str(class_id)
attr_ids = class_attr_map[class_id]
value = json.dumps(attr_ids, ensure_ascii=False)
db.hset(name="jd_ext_attr", key=key, value=value)
......
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 sign in to comment