Redis 常用命令
启动客户端
shell
./redis-cli -h 192.168.3.4 -p 6379 -a root
-h: host 的意思, redis 启动地址的 ip
-p: 端口, 默认是 6379
-a: 设置的密码
如果是本机启动, 端口不变, 则可以省略 -h -p, 直接运行 ./redis-cli -a root, 没有密码直接执行 ./redis-cli退出
shell
quitString 类型基本操作
插入数据, 插入的大数据, 默认在 0 号库
shell
语法: set key value
例如: set username itdachen查看数据
shell
语法: get key
例如: get username切换 Redis 库
shell
语法: select index
例如: select 2层级存储: 层级存储, 针对 key 做层级, 简单点讲, 就像文件夹, 一个套一个, 中间用冒号连接
shell
语法: set xxx:ccc:vvv
例如: set com:itdachen:username itdachen
获取数据: get com:itdachen:username查看当前库有多少 key
shell
keys *关于 info
查看 cpu
shell
info CPU查看主从
shell
info repilication查看集群
shell
info cluster查看详细 info 信息
shell
info清除 key
shell
FLUSHALL该命令清除全部 key, 包括其他库
剑鸣秋朔