redis重置某些key

redis重置某些key

 

import redis

client_redis1 = redis.StrictRedis(host='127.0.0.1', port=6379, db=0, password ="123123")

#1
client1_all_keys = client_redis1.keys()

for indexKey in client1_all_keys:
    if client_redis1.exists(indexKey):
        if "201410" in str(indexKey) or "101180" in str(indexKey):
            print(indexKey)
            data2 = "{\"direction\":13,\"height\":0.0,\"lat\":0.0,\"lng\":0.0,\"receive\":1668143950000,\"sn\":\"201410035\",\"speed\":7.45,\"status\":1}"
            client_redis1.set(indexKey, data2)

 

 

######################

posted @ 2022-11-13 16:50  西北逍遥  阅读(125)  评论(0编辑  收藏  举报