redis 5種資料類型增刪改查

來源:互聯網
上載者:User

標籤:inf   字串   並集   直接   style   資料   src   技術分享   分享圖片   

 1 #  字串 string 2 (1)添加資料 3 set key value  # 添加一條 4 mset key value [key value...]  # 添加多條 5 append  key value  # 添加到末尾

 

 6 (2) 刪除資料 7 del key # 刪除key 8 flushdb  #刪除當前資料庫所有key 9 flushall  # 刪除所有10 11 (3) 修改資料12 rename key newkey   #改名13 set key value  # 直接替換14 (4)查看資料15 get key  #查看一條16 mget key [key...]  # 查看多條17 keys * # 查看所有key

 


 

 1 #列表list 2 (1) 添加資料 3 lpush key value [value...]  # 頭部插入
 4 rpush key value [value...]  # 尾部插入 5 (2)刪除資料 6 lpop key # 刪除左邊第一個 7 rpop  key  # 刪除右邊第一個 8 lrem key count value # 刪除指定數量的值

 

 9 (3)修改資料10 lset key index newvalue  # 指定索引號修改11 (4)查看資料12 lindex key index # 返回指定索引值13 lrange key start stop  # 查看索引範圍內的值14 llen key # 查看長度
 1 # 雜湊 hash 2 (1) 添加資料 3 hset key field value  # 添加一條 4 hmset key field value [field value...] 5 

 

 6 (2)刪除資料 7 hdel key field 8 (3)修改資料 9 ‘‘‘覆蓋‘‘‘10 (4)查看資料11 hget key field  # 擷取value12 hmget key field [field...]  # 擷取多個value13 hvals key # 擷取全部value14 hkeys key  # 擷取全部field15 hgetall key  # 擷取全部field 和 value16 hlen key  # 查看有幾個索引值對
 1 # 集合 set 2 (1)增 3 sadd key member [member...]   #增加元素 4 (2)刪 5 srem key member [member...] #移除元素 6 spop key # 隨機刪除 7 (3)改 8 (4)查 9 scard key # 返回key中元素個數10 smemebers key # 擷取集合中所有元素

 

11 (5)交集12 sinter my_set1 my_set2 # 求交集13 sinterstore newset my_set1 my_set2 # 交集合并到新集合14 15 (6)並集16 sunion key1 key2  # 求並集17 sunionstore newkey key1 key2 # 並集合并到新集合

 

18 (7)差集19 sdiff key1 key2  # 差集20 sdiffstore newkey key1 key2 # 差集合并到新集合
 1 # 有序集合 zset 2 (1)增 3 zadd key score member[ [score member] ..] 4 (2)刪 5 zrem key member [member...]  #移除有序集合中的一個或多個元素,若member不存在則忽略; 6 zremrangebyrank min max : 7     # 刪除集合中 score 在給定區間的元素 8 (3)改 9 (4)查10 zscore key member  # 查看score值11 zrange key start stop[withscores] #按索引返回key的成員, withscores表示顯示score12 zrangebyscore key min max  #返回集合中 score 在給定區間的元素

 

redis 5種資料類型增刪改查

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.