• Python-rediscluster客户端


    
    
    # -*- coding: UTF-8 -*-
    import redis
    import sys
    from rediscluster import StrictRedisCluster
    #host = "172.17.155.118"
    #port = 6379
    #passwd = ""
    instance_ip = sys.argv[1]
    instance_port = sys.argv[2]
    startup_nodes = [{"host": instance_ip, "port": instance_port }]
    rc = StrictRedisCluster(startup_nodes=startup_nodes, decode_responses=True, password="")
    def check_key(rc,k):
        key_len = 0
        big_key = []
        try:
            type = rc.type(k)
            if type == "string":
                key_len = rc.strlen(k)
            elif type == "hash":
                key_len = rc.hlen(k)
            elif type == "list":
                key_len = rc.llen(k)
            elif type == "set":
                key_len = rc.scard(k)
            elif type == "zset":
                key_len = rc.zcard(k)
            else:
                print("Redis key type: "+type)
        except Exception:
            print("Redis key type error.")
        if key_len > 5:
            big_key.append(k)
            big_key.append(type)
            big_key.append(key_len)
            print(big_key)
    
    def scan_key(rc):
        rc_end = []
        try:
            rc_end = rc.scan_iter("*")
        except Exception as e:
            pass
            #print(e)
        for k in rc_end:
            check_key(rc,k)
    
    if __name__ == '__main__':
        scan_key(rc)
    
    
    
     
    一、安装Python3
    1
    . yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel 2. https://www.python.org/ftp/python 3. tar -zxvf Python-3.7.4.tgz mkdir /usr/local/python3 cd Python-3.7.0 ./configure --prefix=/usr/local/python3 make && make install 4. 创建软链 ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3 ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
    二、安装python redis-cluster
    pip3 install redis-py-cluster
  • 相关阅读:
    Python 模块chardet安装 setup.py
    Windows下Python安装lxml
    intellij idea 如何更改比编辑器文本字体和大小
    [转]C#设计模式(8)-Builder Pattern
    [转]C#设计模式(4)-Simple Factory Pattern
    [转]C#委托的异步调用
    [转]浅谈C#中常见的委托
    C# 线程池
    [转]C#中的委托和事件(续)
    C#(.net)中的DllImport
  • 原文地址:https://www.cnblogs.com/lwhctv/p/10767794.html
Copyright © 2020-2023  润新知