redis连接客户端的简单使用

redis连接客户端的简单使用

redis-cli -h
select 选择分区


用法:redis-cli [OPTIONS] [cmd [arg [arg ...]]]
  -h <hostname> 服务器主机名(默认值:127.0.0.1)。
  -p <port> 服务器端口(默认:6379)。
  -s <socket> 服务器套接字(覆盖主机名和端口)。
  -a <password> 连接到服务器时使用的密码。
      您还可以使用 REDISCLI_AUTH 环境
      变量以更安全地传递此密码
      如果两者都使用,则此参数优先)。
  -u <uri> 服务器 URI。
  -r <repeat> 执行指定命令 N 次。
  -i <interval> 使用 -r 时,每个命令等待 <interval> 秒。
                可以指定像 -i 0.1 这样的亚秒级时间。
  -n <db> 数据库编号。
  -x 从 STDIN 读取最后一个参数。
  -d <delimiter> 用于原始格式的多块分隔符(默认值:\n)。
  -c 启用集群模式(遵循 -ASK 和 -MOVED 重定向)。
  --raw 对回复使用原始格式(STDOUT 为默认值时)
                     不是 tty)。
  --no-raw 强制格式化输出,即使 STDOUT 不是 tty。
  --csv 以 CSV 格式输出。
  --stat 打印关于服务器的滚动统计信息:内存、客户端、...
  --latency 进入特殊模式,持续采样延迟。
            如果您在交互式会话中使用此模式,它会运行
            永远显示实时统计数据。否则,如果 --raw 或
            --csv 已指定,或者如果您将输出重定向到非
            TTY,它采样 1 秒的延迟(您可以使用
            -i 更改间隔),然后生成单个输出并退出。
  --latency-history 与 --latency 类似,但跟踪延迟随时间的变化。
                     默认时间间隔为 15 秒。使用 -i 更改它。
  --latency-dist 将延迟显示为光谱,需要 xterm 256 色。
                     默认时间间隔为 1 秒。使用 -i 更改它。
  --lru-test <keys> 模拟 80-20 分布的缓存工作负载。
  --replica 模拟一个副本,显示从主服务器接收到的命令。
  --rdb <filename> 将 RDB 转储从远程服务器传输到本地文件。
  --pipe 将原始 Redis 协议从标准输入传输到服务器。
  --pipe-timeout <n> 在 --pipe 模式下,如果在发送所有数据后出错,则中止。
                     <n> 秒内未收到回复。
                     默认超时:30。使用 0 永远等待。
  --bigkeys 示例 Redis 键寻找具有许多元素(复杂性)的键。
  --memkeys 示例 Redis 键寻找消耗大量内存的键。
  --memkeys-samples <n> 示例 Redis 键,查找消耗大量内存的键。
                     并定义要采样的关键元素的数量
  --hotkeys 查找热键的示例 Redis 键。
                     仅当 maxmemory-policy 为 *lfu 时才有效。
  --scan 使用 SCAN 命令列出所有键。
  --pattern <pat> 与 --scan 一起用于指定扫描模式。
  --intrinsic-latency <sec> 运行测试以测量内部系统延迟。
                     测试将运行指定的秒数。
  --eval <file> 使用 <file> 中的 Lua 脚本发送 EVAL 命令。
  --ldb 与 --eval 一起使用启用 Redis Lua 调试器。
  --ldb-sync-mode 与 --ldb 类似,但使用同步 Lua 调试器,在
                     此模式服务器被阻止并且脚本更改是
                     不从服务器内存回滚。
  --cluster <命令> [参数...] [选项...]
                     集群管理器命令和参数(见下文)。
  --verbose 详细模式。
  --no-auth-warning 在命令上使用密码时不显示警告消息
                     线接口。
  --help 输出此帮助并退出。
  --version 输出版本并退出。

集群管理器命令:
  使用 --cluster help 列出所有可用的集群管理器命令。

例子:
  cat /etc/passwd | redis-cli -x 设置 mypasswd
  redis-cli 获取 mypasswd
  redis-cli -r 100 lpush mylist x
  redis-cli -r 100 -i 1 信息 | grep used_memory_human:
  redis-cli --eval myscript.lua key1 key2 , arg1 arg2 arg3
  redis-cli --scan --pattern '*:12345*'

  (注意:使用 --eval 时,逗号将 KEYS[] 与 ARGV[] 项分开)

当没有给出命令时,redis-cli 以交互模式启动。
在交互模式下键入“help”以获取有关可用命令的信息
和设置。 

redis-cli -p 6380 指定端口号连接
redis-cli -n 9 指定分区连接 redis共16个分区供选择,每个分区的键值对数据是不相通的,就像mysql的数据库一样

help
redis-cli 5.0.5
To get help about Redis commands type:
      "help @<group>" to get a list of commands in <group>
      "help <command>" for help on <command>
      "help <tab>" to get a list of possible help topics
      "quit" to exit

To set redis-cli preferences:
      ":set hints" enable online hints
      ":set nohints" disable online hints
Set your preferences in ~/.redisclirc
redis-cli 5.0.5
要获取有关 Redis 命令的帮助,请键入:
       "help @<group>" 获取<group> 中的命令列表
       "help <command>" 获取有关 <command> 的帮助
       "help <tab>" 获取可能的帮助主题列表
       “退出”退出

设置 redis-cli 首选项:
       ":set hints" 启用在线提示
       ":set nohints" 禁用在线提示
在 ~/.redisclirc 中设置您的首选项

在连接内
help 加命令会告诉你怎么去用这个命令

help set

  SET key value [expiration EX seconds|PX milliseconds] [NX|XX]
  summary: Set the string value of a key
  since: 1.0.0
  group: string

help @generic 分组 通用组 回车之后告诉你有哪些命令属于这个组的

help @generic

  DEL key [key ...]
  summary: Delete a key
  since: 1.0.0

  DUMP key
  summary: Return a serialized version of the value stored at the specified key.
  since: 2.6.0

  EXISTS key [key ...]
  summary: Determine if a key exists
  since: 1.0.0

  EXPIRE key seconds
  summary: Set a key's time to live in seconds
  since: 1.0.0

  EXPIREAT key timestamp
  summary: Set the expiration for a key as a UNIX timestamp
  since: 1.2.0

  KEYS pattern
  summary: Find all keys matching the given pattern
  since: 1.0.0

  MIGRATE host port key| destination-db timeout [COPY] [REPLACE] [KEYS key]
  summary: Atomically transfer a key from a Redis instance to another one.
  since: 2.6.0

  MOVE key db
  summary: Move a key to another database
  since: 1.0.0

  OBJECT subcommand [arguments [arguments ...]]
  summary: Inspect the internals of Redis objects
  since: 2.2.3

  PERSIST key
  summary: Remove the expiration from a key
  since: 2.2.0

  PEXPIRE key milliseconds
  summary: Set a key's time to live in milliseconds
  since: 2.6.0

  PEXPIREAT key milliseconds-timestamp
  summary: Set the expiration for a key as a UNIX timestamp specified in milliseconds
  since: 2.6.0

  PTTL key
  summary: Get the time to live for a key in milliseconds
  since: 2.6.0

  RANDOMKEY -
  summary: Return a random key from the keyspace
  since: 1.0.0

  RENAME key newkey
  summary: Rename a key
  since: 1.0.0

  RENAMENX key newkey
  summary: Rename a key, only if the new key does not exist
  since: 1.0.0

  RESTORE key ttl serialized-value [REPLACE]
  summary: Create a key using the provided serialized value, previously obtained using DUMP.
  since: 2.6.0

  SCAN cursor [MATCH pattern] [COUNT count]
  summary: Incrementally iterate the keys space
  since: 2.8.0

  SORT key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC|DESC] [ALPHA] [STORE destination]
  summary: Sort the elements in a list, set or sorted set
  since: 1.0.0

  TOUCH key [key ...]
  summary: Alters the last access time of a key(s). Returns the number of existing keys specified.
  since: 3.2.1

  TTL key
  summary: Get the time to live for a key
  since: 1.0.0

  TYPE key
  summary: Determine the type stored at key
  since: 1.0.0

  UNLINK key [key ...]
  summary: Delete a key asynchronously in another thread. Otherwise it is just as DEL, but non blocking.
  since: 4.0.0

  WAIT numreplicas timeout
  summary: Wait for the synchronous replication of all the write commands sent in the context of the current connection
  since: 3.0.0

  XSETID key arg 
  summary: Help not available
  since: not known

  RESTORE-ASKING key arg arg ...options...
  summary: Help not available
  since: not known

  LATENCY arg ...options...
  summary: Help not available
  since: not known

  PFSELFTEST 
  summary: Help not available
  since: not known

  PFDEBUG arg arg ...options...
  summary: Help not available
  since: not known

  POST ...options...
  summary: Help not available
  since: not known

  HOST: ...options...
  summary: Help not available
  since: not known

  GEORADIUSBYMEMBER_RO key arg arg arg ...options...
  summary: Help not available
  since: not known

  LOLWUT ...options...
  summary: Help not available
  since: not known

  MODULE arg ...options...
  summary: Help not available
  since: not known

  REPLCONF ...options...
  summary: Help not available
  since: not known

  GEORADIUS_RO key arg arg arg arg ...options...
  summary: Help not available
  since: not known

  PSYNC arg arg 
  summary: Help not available
  since: not known

  ASKING 
  summary: Help not available
  since: not known

  SUBSTR key arg arg 
  summary: Help not available
  since: not known

help 直接tab键会提示

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值