Redis數(shù)據(jù)類型使用

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

  1. "loglevel"
  2. "debug"
    第三步設(shè)置密碼并登陸:
    localhost:6379> config set requirepass 123456
    OK
    localhost:6379> AUTH 123456
    OK
    查看密碼:
    localhost:6379> CONFIG GET requirepass
  3. "requirepass"
  4. "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"
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容