设为首页收藏本站 JeeStudy企业开发官网①

JEE Study|JAVA EE|企业级开发学习网

 找回密码
 立即加入

QQ登录

只需一步,快速开始

扫一扫,访问微社区

搜索
查看: 1666|回复: 0
打印 上一主题 下一主题

Redis 命令

[复制链接]

219

主题

221

帖子

1418

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1418

最佳新人活跃会员热心会员推广达人宣传达人灌水之王突出贡献优秀版主荣誉管理论坛元老

跳转到指定楼层
楼主
发表于 2020-5-9 13:50:51 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Redis 命令
Redis 命令用于在 redis 服务上执行操作。
要在 redis 服务上执行命令需要一个 redis 客户端。Redis 客户端在我们之前下载的的 redis 的安装包中。
语法
Redis 客户端的基本语法为:
$ redis-cli实例
以下实例讲解了如何启动 redis 客户端:
启动 redis 客户端,打开终端并输入命令 redis-cli。该命令会连接本地的 redis 服务。
$redis-cli
redis 127.0.0.1:6379>
redis 127.0.0.1:6379> PING
PONG
在以上实例中我们连接到本地的 redis 服务并执行 PING 命令,该命令用于检测 redis 服务是否启动。

在远程服务上执行命令
如果需要在远程 redis 服务上执行命令,同样我们使用的也是 redis-cli 命令。
语法
$ redis-cli -h host -p port -a password
实例
以下实例演示了如何连接到主机为 127.0.0.1,端口为 6379 ,密码为 mypass 的 redis 服务上。
$redis-cli -h 127.0.0.1 -p 6379 -a "mypass"
redis 127.0.0.1:6379> PING
PONG


显示帮助

$redis-cli  --help

>redis-cli --help
redis-cli 3.0.501

Usage: redis-cli [OPTIONS] [cmd [arg [arg ...]]]
  -h <hostname>      Server hostname (default: 127.0.0.1).
  -p <port>               Server port (default: 6379).
  -s <socket>            Server socket (overrides hostname and port).
  -a <password>       Password to use when connecting to the server.
  -r <repeat>             Execute specified command N times.
  -i <interval>           When -r is used, waits <interval> seconds per command.It is possible to specify sub-second times like -i 0.1.
  -n <db>                 Database number.
  -x                            Read last argument from STDIN.
  -d <delimiter>       Multi-bulk delimiter in for raw formatting (default: \n).
  -c                            Enable cluster mode (follow -ASK and -MOVED redirections).
  --raw                      Use raw formatting for replies (default when STDOUT is not a tty).
  --no-raw                Force formatted output even when STDOUT is not a tty.
  --csv                       Output in CSV format.
  --stat                      Print rolling stats about server: mem, clients, ...
  --latency                Enter a special mode continuously sampling latency.
  --latency-history    Like --latency but tracking latency changes over time.Default time interval is 15 sec. Change it using -i.
  --latency-dist         Shows latency as a spectrum, requires xterm 256 colors. Default time interval is 1 sec. Change it using -i.
  --lru-test <keys>  Simulate a cache workload with an 80-20 distribution.
  --slave                    Simulate a slave showing commands received from the master.
  --rdb <filename>   Transfer an RDB dump from remote server to local file.
  --pipe                      Transfer raw Redis protocol from stdin to server.
  --pipe-timeout <n> In --pipe mode, abort with error if after sending all data. no reply is received within <n> seconds.Default timeout: 30.  Use 0 to wait forever.
  --bigkeys                 Sample Redis keys looking for big keys.
  --scan                      List all keys using the SCAN command.
  --pattern <pat>      Useful with --scan to specify a SCAN pattern.
  --intrinsic-latency <sec> Run a test to measure intrinsic system latency. The test will run for the specified amount of seconds.
  --eval <file>            Send an EVAL command using the Lua script at <file>.
  --help                      Output this help and exit.
  --version                 Output version and exit.

Examples:
  cat /etc/passwd | redis-cli -x set mypasswd
  redis-cli get mypasswd
  redis-cli -r 100 lpush mylist x
  redis-cli -r 100 -i 1 info | grep used_memory_human:
  redis-cli --eval myscript.lua key1 key2 , arg1 arg2 arg3
  redis-cli --scan --pattern '*:12345*'

  (Note: when using --eval the comma separates KEYS[] from ARGV[] items)

When no command is given, redis-cli starts in interactive mode.Type "help" in interactive mode for information on available commands.











知识改变命运!

JAVA EE 学习     JAVA EE 资料
JEE Study:企业级开发学习网!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即加入

本版积分规则

QQ|Archiver|手机版|小黑屋|JEE Study ( 京ICP备16036936   JeeStudy企业开发官网①

GMT+8, 2024-4-25 08:20 , Processed in 0.223922 second(s), 27 queries .

Powered by JeeStudy!

© 2008-2020 JEE Study 企业级开发学习网

快速回复 返回顶部 返回列表