Redis的LogLevel有4個級別
1、debug 2、verbose 3、notice 4、warning
但是默認是:loglevel notice
第一步先啟動服務(wù)端:
redis-server redis.windows.conf
第二步啟動客戶端:
redis-cli.exe -h localhost -p 6379
查看客戶端是否連通:
localhost:6379> ping
PONG
出現(xiàn)PONG即為連通
設(shè)置并查看日志級別:
CONFIG set loglevel debug
OK
localhost:6379> CONFIG GET loglevel
- "loglevel"
- "debug"
第三步設(shè)置密碼并登陸:
localhost:6379> config set requirepass 123456
OK
localhost:6379> AUTH 123456
OK
查看密碼:
localhost:6379> CONFIG GET requirepass - "requirepass"
- "123456"
// 設(shè)置獲取 string
localhost:6379> set ysx yanshixian
OK
localhost:6379> get ysx
"yanshixian"
// 存儲 hash 類型,適合存儲對象。
localhost:6379> hmset stu0 sid 02142010 score 99 name ysx
OK
localhost:6379> hmset stu1 sid 02142011 score 100 name yanshixian
OK
localhost:6379> hgetall stu0
1) "sid"
2) "02142010"
3) "score"
4) "99"
5) "name"
6) "ysx"
localhost:6379> hgetall stu1 sid
(error) ERR wrong number of arguments for 'hgetall' command
localhost:6379> hget stu1 sid
"02142011"
//3. lists:(1)重復(fù)有序,返回下標索引。(2)redis的list基于鏈表,查詢慢,插?刪除快。
//左側(cè)插?
localhost:6379> lpush subject java
(integer) 1
localhost:6379> lpush subject html5
(integer) 2
localhost:6379> lpush subject python
(integer) 3
localhost:6379> lrange subject 1 100
1) "html5"
2) "java"
localhost:6379> lrange subject start stop
//右側(cè)插?
localhost:6379> rpush bike hello
(integer) 1
localhost:6379> rpush bike ofo
(integer) 2
localhost:6379> rpush bike blue
(integer) 3
localhost:6379> lrange bike 0 100
1) "hello"
2) "ofo"
3) "blue"
//4. set ?序集合,不重復(fù),返回受影響?數(shù)。
localhost:6379> sadd week monday
(integer) 1
localhost:6379> sadd week WenDay
(integer) 1
localhost:6379> sadd week ysx
(integer) 1
localhost:6379> smembers week
1) "monday"
2) "WenDay"
3) "ysx"
//5. zset 有序集合,不重復(fù)。
localhost:6379> zadd java 100 yiyi
(integer) 1
localhost:6379> zadd java 100 erer
(integer) 1
localhost:6379> zadd java 99 sansan
(integer) 1
localhost:6379> zrangebyscore java 0 3
(empty list or set)
localhost:6379> zrangebyscore java 0 99
1) "sansan"
localhost:6379> zrangebyscore java 100 100
1) "erer"
2) "yiyi"