标签:normal pool int utf-8 += 查询 import member connect
# encoding: utf-8 import redis import random import string import time #use scan_iter count redis key #support key prefix # pool = redis.ConnectionPool(host=‘192.168.50.203‘, port=7001,password=‘A95clrfGuwu‘, db=0) r = redis.Redis(connection_pool=pool) def select_redis_key(): start_time = time.time() prefix_key = "AGENT_MEMBER_MSG_UNREAD_" result_length = 0 for key in r.scan_iter(match=‘AGENT_MEMBER_MSG_UNREAD_*‘, count=100): result_length += 1 #print result_length,‘ is ‘,key print "normal ways spend time(s) is :", time.time() - start_time print "normal way seelect the keys with prefix" ,prefix_key, "count(*) is :", result_length def main(): select_redis_key() if __name__ == ‘__main__‘: main()
标签:normal pool int utf-8 += 查询 import member connect
原文地址:https://www.cnblogs.com/monkeybron/p/11307218.html