zoukankan      html  css  js  c++  java
  • 清理redis的key

    import redis
    import time
    
    pool=redis.ConnectionPool(host='xxxxxxx', port=6379, max_connections=100)
    
    r = redis.StrictRedis(connection_pool=pool)
    
    
    def del_keys_with_pipe():
        start_time = time.time()
        result_length = 0
        pipe = r.pipeline()
        for key in r.scan_iter(match='sociaxx*', count=2000):
            pipe.delete(key)
            result_length += 1
            if result_length % 2000 == 0:
                 pipe.execute()
        ip_time = time.time()
        print("use pipeline scan time :", time.time() - start_time)
        pipe.execute()
    
        print ("use pipeline ways delete numbers:", result_length)
    
    if  __name__ == '__main__':
        del_keys_with_pipe()
    

      

    业余经济爱好者
  • 相关阅读:
    CSS切割
    一台电脑 多个 tomcat
    CGI
    电源关系
    Monkey Test 命令使用
    html ul
    java 反射
    RTMP
    动态库
    flash 大文件上传
  • 原文地址:https://www.cnblogs.com/5sdba-notes/p/14613839.html
Copyright © 2011-2022 走看看