Commit c911f510 authored by 张彦钊's avatar 张彦钊

change test file

parent 93d172bd
...@@ -76,19 +76,20 @@ def write_redis(device_id,cid_list): ...@@ -76,19 +76,20 @@ def write_redis(device_id,cid_list):
"and c.id = {} and c.tag_type = '3'".format(tags) "and c.id = {} and c.tag_type = '3'".format(tags)
cursor.execute(sql) cursor.execute(sql)
result = cursor.fetchall() result = cursor.fetchall()
cids = list(set([i[0] for i in result])) return result
if len(cids) != 0: # cids = list(set([i[0] for i in result]))
# if len(cids) != 0:
r = redis.StrictRedis.from_url('redis://:ReDis!GmTx*0aN6@172.16.40.133:6379') #
key = str(device_id) + "_dislike_diary" # r = redis.StrictRedis.from_url('redis://:ReDis!GmTx*0aN6@172.16.40.133:6379')
if r.exists(key): # key = str(device_id) + "_dislike_diary"
value = eval(r.get(key)) # if r.exists(key):
value.extend(cids) # value = eval(r.get(key))
cids = json.dumps(list(set(value))) # value.extend(cids)
r.set(key, json.dumps(cids)) # cids = json.dumps(list(set(value)))
else: # r.set(key, json.dumps(cids))
r.set(key, json.dumps(cids)) # else:
r.expire(key, 60*60) # r.set(key, json.dumps(cids))
# r.expire(key, 60*60)
except Exception as e: except Exception as e:
print("insert redis fail") print("insert redis fail")
......
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