1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import redis
def getRedisConn4():
pool = redis.ConnectionPool(host="172.16.50.145",password="XfkMCCdWDIU%ls$h",port=6379,db=0)
conn = redis.Redis(connection_pool=pool)
# conn = redis.Redis(host="172.16.50.145", port=6379, password="XfkMCCdWDIU%ls$h",db=0)
# conn = redis.Redis(host="172.18.51.10", port=6379,db=0) #test
return conn
def getRedisConn():
pool = redis.ConnectionPool(host="172.16.40.133",password="ReDis!GmTx*0aN6",port=6379,db=0)
conn = redis.Redis(connection_pool=pool)
# conn = redis.Redis(host="172.16.50.145", port=6379, password="XfkMCCdWDIU%ls$h",db=0)
# conn = redis.Redis(host="172.18.51.10", port=6379,db=0) #test
return conn
if __name__ == '__main__':
# REDIS_URL = 'redis://:@172.18.51.10:6379'
# redis_client = redis.StrictRedis.from_url(REDIS_URL, decode_responses=True)
# # redisKey = "service_recommend_read_cache_869982038583034"
# redisKey = "strategy:icon:click:869982038583034"
#
# d = {"1":1,"2":2}
# redis_client.hmset(redisKey,d)
# m = redis_client.hgetall(redisKey)
# pipline = redis_client.pipeline()
# for k,v in m.items():
# # print(k,v)
# pipline.hdel(redisKey,k)
# pipline.execute()
# pipline.close()
#
# m = redis_client.hgetall(redisKey)
# redis_client.hincrby(redisKey,"3",5)
# m = redis_client.hgetall(redisKey)
# redis_client.expire(redisKey,60*60*24*7)
# for k, v in m.items():
# print(k, v)
pass