Redis第二篇(Redis基本命令)

-x     从标准输入读取一个参数

such as:

echo –en “shaw” |./redis-cli –x setname == set name shaw

-r     重复执行一个命令指定的次数

-i     设置命令执行的间隔

such as:

1
2
3
4
5
[root@M2_Redis1 src]# ./redis-cli -r 100 -i 1 info | grep total_commands_processed      # 每隔1秒执行一次,共执行100次info命令
total_commands_processed:140
total_commands_processed:141
total_commands_processed:142
total_commands_processed:143

--rdb      获取指定redis实例的rdb文件,保存到本地

例如:

1
2
3
[root@M2_Redis1 src]# ./redis-cli --rdb /home/tools/6379.rdb
SYNC sent to master, writing 31 bytes to '/home/tools/6379.rdb'
Transfer finished with success.

--scan     利用scan命令扫描列出redis中的key

--pattern     指定扫描的key的pattern,相比keys pattern模式,不会长时间阻塞redis而导致其他客户端的命令请求一直处于阻塞状态

例如:

1
2
[root@M2_Redis1 src]# ./redis-cli --scan --pattern 'na*'
name

-h     指定被链接的ip

-p     指定连接端口

-a     指定连接的用户的密码,也可以连接完成后,用auth命令完成授权

-s     只有客户端和服务端在同一个机器,可以通过unix socket方式连接

--stat     获取redis的诊断数据

例如:

1
2
3
4
5
6
7
[root@M2_Redis1 src]# ./redis-cli --stat
------- data ------ --------------------- load -------------------- - child -
keys       mem      clients blocked requests            connections         
1          1.78M    1       0       169 (+0)            22         
1          1.78M    1       0       170 (+1)            22         
1          1.78M    1       0       171 (+1)            22         
1          1.78M    1       0       172 (+1)            22         

--pipe     发送原始的redis protocl格式数据到服务器端执行

--bigkeys     对redis中的key进行采样,寻找较大的keys,还能根据采样得出大概的数据统计

例如:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@M2_Redis1 src]# ./redis-cli --bigkeys
# Scanning the entire keyspace to find biggest keys as well as
# average sizes per key type.  You can use -i 0.1 to sleep 0.1 sec
# per 100 SCAN commands (not usually needed).
[00.00%] Biggest string found so far 'name' with 4 bytes
-------- summary -------
Sampled 1 keys in the keyspace!
Total key length in bytes is 4 (avg len 4.00)
 
Biggest string found 'name' has 4 bytes
 
1 strings with 4 bytes (100.00% of keys, avg size 4.00)
0 lists with 0 items (00.00% of keys, avg size 0.00)
0 sets with 0 members (00.00% of keys, avg size 0.00)
0 hashs with 0 fields (00.00% of keys, avg size 0.00)
0 zsets with 0 members (00.00% of keys, avg size 0.00)

--latency     获取到命令的请求时间,包括(min,max,avg)

待补充完善。。。

 
上一篇:Android学习笔记(六)——活动的启动模式


下一篇:吴恩达机器学习笔记49-主成分分析问题(Principal Component Analysis Problem Formulation)