一:redis安装

  python操作redis分为两部分,一为安装redis程序 二是安装支持python操作redis的模块

  1)安装redis

    redis 官方网站:http://www.redis.cn/

    Redis 没有官方的Windows版本,但是微软开源技术团队(Microsoft Open Tech group)开发和维护着这个 Win64 的版本

    https://github.com/MicrosoftArchive/redis/releases

     

   linux安装 

wget http://download.redis.io/releases/redis-4.0.1.tar.gz
tar xvzf redis-4.0.1.tar.gz
cd redis-4.0.1/
make

 

  make完后redis-4.0.1

  目录下会出现编译后的redis服务程序redis-server,还有用于测试的客户端程序redis-cli,两个程序位于安装目录 src 目录下:

  下面启动redis服务.

  
  $ cd src
  $ ./redis-server

 

  注意这种方式启动redis 使用的是默认配置。也可以通过启动参数告诉redis使用指定配置文件使用下面命令启动。

  $ cd src
  $ ./redis-server redis.conf

 

  redis.conf是一个默认的配置文件。我们可以根据需要使用自己的配置文件。

  启动redis服务进程后,就可以使用测试客户端程序redis-cli和redis服务交互了

  2)python安装redis模块

    

pip install redis  

 

Redis 的配置文件位于 Redis 安装目录下,文件名为 redis.conf。

你可以通过 CONFIG 命令查看或设置配置项。


语法

Redis CONFIG 命令格式如下:

redis 127.0.0.1:6379> CONFIG GET CONFIG_SETTING_NAME

实例

redis 127.0.0.1:6379> CONFIG GET loglevel

1) "loglevel"
2) "notice"

使用 * 号获取所有配置项:

实例

redis 127.0.0.1:6379> CONFIG GET *

  1) "dbfilename"
  2) "dump.rdb"
  3) "requirepass"
  4) ""
  5) "masterauth"
  6) ""
  7) "unixsocket"
  8) ""
  9) "logfile"
 10) ""
 11) "pidfile"
 12) "/var/run/redis.pid"
 13) "maxmemory"
 14) "0"
 15) "maxmemory-samples"
 16) "3"
 17) "timeout"
 18) "0"
 19) "tcp-keepalive"
 20) "0"
 21) "auto-aof-rewrite-percentage"
 22) "100"
 23) "auto-aof-rewrite-min-size"
 24) "67108864"
 25) "hash-max-ziplist-entries"
 26) "512"
 27) "hash-max-ziplist-value"
 28) "64"
 29) "list-max-ziplist-entries"
 30) "512"
 31) "list-max-ziplist-value"
 32) "64"
 33) "set-max-intset-entries"
 34) "512"
 35) "zset-max-ziplist-entries"
 36) "128"
 37) "zset-max-ziplist-value"
 38) "64"
 39) "hll-sparse-max-bytes"
 40) "3000"
 41) "lua-time-limit"
 42) "5000"
 43) "slowlog-log-slower-than"
 44) "10000"
 45) "latency-monitor-threshold"
 46) "0"
 47) "slowlog-max-len"
 48) "128"
 

相关文章:

  • 2021-11-25
  • 2021-11-09
  • 2022-12-23
  • 2021-04-14
  • 2021-06-12
  • 2021-04-10
猜你喜欢
  • 2021-07-08
  • 2021-11-28
  • 2021-11-04
  • 2022-02-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案