1.ping:测试服务器是否存
127.0.0.1:6379> ping
PONG
ping pong类似于打乒乓球,pong说明服务器有相应。
然后我们把redis关闭掉
127.0.0.1:6379> ping
Could not connect to Redis at 127.0.0.1:6379: Connection refused
可以看到已经连接不上了
然后再启动redis
127.0.0.1:6379> ping
PONG
2.echo content 再命令行输出content
127.0.0.1:6379> echo 'test echo'
"test echo"
3.select dbindex:选择数据库。Redis数据库的编号是0-15,我们可以选择任意一个数据库来进行数据的存取。当选择16时会报错。
127.0.0.1:6379> select 11
OK
127.0.0.1:6379> select 16
(error) ERR invalid DB index
5.dbsize:返回当前数据库中key的数目
127.0.0.1:6379> select 0
OK
127.0.0.1:6379> keys *
1) "key2"
2) "key4"
3) "key1"
4) "key3"
5) "zsetkey1"
127.0.0.1:6379> dbsize
(integer) 5
127.0.0.1:6379> select 1
OK
127.0.0.1:6379> keys *
(empty list or set)
127.0.0.1:6379> dbsize
(integer) 0
127.0.0.1:6379> config get dir
1) "dir"
2) "/usr/local/redis-2.8.1/src"
127.0.0.1:6379> config get timeout
1) "timeout"
2) "0"
如果用config get *可以将所有的配置信息取出
127.0.0.1:6379[1]> dbsize
(integer) 1
127.0.0.1:6379[1]> keys *
1) "listkey1"
127.0.0.1:6379[1]> flushdb
OK
127.0.0.1:6379[1]> keys *
(empty list or set)
127.0.0.1:6379[1]> select 0 OK 127.0.0.1:6379> dbsize (integer) 1 127.0.0.1:6379> select 1 OK 127.0.0.1:6379[1]> dbsize (integer) 2 127.0.0.1:6379[1]> flushall OK 127.0.0.1:6379[1]> dbsize (integer) 0 127.0.0.1:6379[1]> select 0 OK 127.0.0.1:6379> dbsize (integer) 0
原文链接:https://www.f2er.com/nosql/204289.html