Commit 8acda2ca authored by 张彦钊's avatar 张彦钊

change test file

parent eefcd8c5
...@@ -76,18 +76,19 @@ def tractate_write(device_id,cid): ...@@ -76,18 +76,19 @@ def tractate_write(device_id,cid):
cursor.execute(sql) cursor.execute(sql)
result = cursor.fetchall() result = cursor.fetchall()
db.close() db.close()
cids = list(set([i[0] for i in result])) cids = [i[0] for i in result]
if len(cids) != 0: if len(cids) != 0:
r = redis.Redis(host="172.16.40.135", port=5379, password="") r = redis.Redis(host="172.16.40.135", port=5379, password="")
key = str(device_id) + "_dislike_tractate" key = str(device_id) + "_dislike_tractate"
if r.exists(key): if r.exists(key):
value = eval(r.get(key)) value = json.loads(r.get(key)).split(",")
value.extend(cids) value.extend(cids)
cids = json.dumps(list(set(value))) cids = json.dumps(",".join(set(value)))
r.set(key, json.dumps(cids)) r.set(key, json.dumps(cids))
print("存在")
else: else:
r.set(key, json.dumps(cids)) r.set(key, json.dumps(",".join(cids)))
r.expire(key, 7*24*60*60) r.expire(key, 7*24*60*60)
# return "tractate good" # return "tractate good"
# #
......
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