码迷,mamicode.com
首页 > 其他好文 > 详细

redis_config

时间:2018-08-02 18:19:57      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:time   int   配置   slow   python   usr   coding   att   key   

#!/usr/bin/python #-*- coding:utf-8 -*- # by MO #DATA 2018-08-02 import redis import datetime RedisHostMessage={     'test':[{'Host':'***',           'Port':6379,           'Pwd':None}], } #查询slowlog def SlowlogGet(*args):     slowlog = connect.slowlog_get()     for msg in slowlog:         print(Host)         for key in msg:             if key == 'start_time':                 print(key, ':', datetime.datetime.fromtimestamp(msg[key]))        #进行时间转换,unix时间转换                 continue             print(key,':',msg[key])         print('----------ID-----------')     # print(slowlog) #查询redis配置 def ConfigGet(*args):     config = connect.config_get(pattern='slowlog*')     for key in config:         print(key,config[key]) #修改redis配置 def ConfigSet(*args):     # connect.config_set('slowlog-log-slower-than',50000)       #配置slowlog阈值时间50ms     connect.slowlog_reset()                                     #重置slowlog list for key in RedisHostMessage:     for message in RedisHostMessage[key]:         Host=message['Host']         Port=message['Port']         Pwd=message['Pwd']         connect = redis.Redis(host=Host, port=Port, password=Pwd)         # print(Host,Port,Pwd)         # SlowlogGet(connect)         ConfigSet(connect)         SlowlogGet(connect)


redis_config

标签:time   int   配置   slow   python   usr   coding   att   key   

原文地址:http://blog.51cto.com/phospherus/2153738

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!