#1 连接redis

#1 连接redis

    -- import redis


    -- 使用端口连接redis
        conn = redis.Redis(host="127.0.0.1", port=6379)

    -- 使用套接字连接
        r = redis.Redis(unix_socket_path='/tmp/redis.sock')
        
    -- 使用连接池连接到redis
        >>> pool = redis.ConnectionPool(host='192.168.56.100', port=6379)
        >>> conn = redis.Redis(connection_pool=pool)
        
    -- 写入一条字符串数据
        conn.set("ranking:category", "hello")
View Code

相关文章:

  • 2022-12-23
  • 2021-10-14
  • 2021-04-01
  • 2021-10-04
  • 2021-08-31
  • 2022-03-03
  • 2021-11-04
猜你喜欢
  • 2021-12-18
  • 2021-10-14
  • 2021-11-16
  • 2020-11-13
  • 2021-09-14
  • 2022-02-20
  • 2022-02-07
相关资源
相似解决方案