redis學習筆記(4) redis常用命令3

2021-10-19 12:13:23 字數 1437 閱讀 4513

手動高亮tip

sadd key number1 number2 … (向集合新增乙個或多個成員)

srem key number1 numner2 … (移除集合中乙個或多個成員)

scard key (獲取集合的成員數)

sdiff key1 key2 … (返回所有集合之間的差集)

sdiffstore destinationkey key1 key2 … (返回給定所有集合的差集並儲存在 destinationkey 中)

sinter key1 key2 … (返回給定所有集合的交集)

sinterstore destinationkey key1 key2 … (返回給定所有集合的交集並儲存在 destinationkeys 中)

sunion key1 key2 … (返回所有給定集合的並集)

sunionstore destinationkey key1 key2 … (所有給定集合的並集儲存在 destinationkey 集合中)

sismember key member (判斷member是否存在於key中)

smembers key (返回key集合中所有成員)

smove sourcekey destinationkey member (將集合sourcekey中的member成員移動到集合destinationkey中)

spop key (隨機移出並返回集合key中的乙個元素)

srandmember key [count] (返回集合中乙個或多個隨機數)

sscan key cursor [match pattern] [count count] (迭代集合中的元素)

zadd source1 member1 source2 member2 … … (向有序集合新增乙個或多個成員,或者更新已存在成員的分數)

zrem key number1 number2 … (移除有序集合中乙個或多個元素)

zcard key (獲得有序集合的成員數)

zcount key min max (獲得指定分數區間的成員數)

zincrby key increment member (有序集合中對所指定成員的分數上加上增量increment)

zrange key start stop [ withscores] (通過索引區間返回有序集合的指定區間內的成員)

zrank key member (返回有序集合中指定成員的索引)

zrevrank key member (返回有序集合中指定成員的排名,有序集成員按分數值遞減(從大到小)排序)

zscore key member (返回集合中指定元素的分數值)

ascan key cursor [match pattern] [count count] (迭代有序集合中的元素(包括元素成員和元素分值))

天賜食於鳥,但絕不投食於巢

Redis學習 4 Redis特性

相關特性 多資料庫 乙個redis例項可以鏈結多個資料庫,客戶端可以指定連線某個redis例項的哪個資料庫 就好像mysql中多個資料庫一樣。乙個redis例項可以提供16個資料庫0 15,客戶端預設連線的第0個資料庫 select x 選擇第x個資料庫 今天在公司加班,所以說換了個crt對伺服器進...

Redis學習筆記4 Redis資料儲存優化機制

1.zipmap優化hash 前面談到將乙個物件儲存在hash型別中會占用更少的記憶體,並且可以更方便的訪問整個物件。省記憶體的原因是新建乙個hash物件時開始是用zipmap來儲存的。這個zipmap其實並不是hash table,但是zipmap相比正常的hash實現可以節省不少hash本身需要...

Linux部署 4 Redis的安裝

將redis的包上傳到你的linux的 usr local temp下 yum install y gcc c 2.直接解壓 tar zxvf redis 3.0.0.tar.gz 3.進入解壓目錄 make 4.接下進入src目錄 進行安裝 make install prefix usr loca...