Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Redis collection how to use Set

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to use the Redis collection Set, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Redis Collection (Set)

Single-valued multiple Value

1.sadd/smembers/sismember

Sadd: addin

Smembers: viewin

Sismember: determine whether it exists or not

127.0.0.1 sadd set011 9736 > smembers set011) 3127.0.1 smembers set011) "1" 2) "2" 3) "3" 127.0.1 sismember set011 (integer) 1127.0.1 VR 9736 > sismember set01 x (integer) 02. Scard, get the number of elements in the collection 127.0.0.1 integer 9736 > scard set01 (integer) 33. Srem key value deletes elements from the collection 127.0.0.1 integer 9736 > srem set01 3 (integer) 1127.0.1 integer 9736 > smembers set011) "1" 2) "2" 4. Srandmember key an integer (randomly selected numbers) 127.0.0.1 srandmember key 9736 > sadd set021 2 3 4 56 7 (integer) 7127.0.0.1 integer 9736 > smembers set021) "1" 2) "2" 3) "3" 4) "4" 5) "5" 6) "6" 7) "7" 127.0.1) SRANDMEMBER set02 31) "2" 2) "3" 3) "5" 5. Spop key random stack 127.0.0.1 spop set02 9736 > SMEMBERS set021) "1" 2) "2" 3) "3" 4) "4" 5) "5" 6) "7" 6. The function of key2 in key1 is to assign a value in key1 to key2127.0.0.1:9736 > SMOVE set02 set03 4 (integer) 1127.0.0.1) 9736 > SMEMBERS set021) "1" 2) "2" 3) "3" 4) "5" 5) "7" 127.0.0.1 key1 9736 > SMEMBERS set031) "x" 2) "z" 3) "4" 4) "y" 127.0.0.1 key1 9736 > 7. Mathematical set Class difference set: sdiff

Items in the first set but not in any subsequent set

127.0.1 SADD set01 9736 > SADD set021 123 4 5 (integer) 5127.0.1 SADD set021 2 a b (integer) 5127.0.1 SADD set021 9736 > SDIFF set01 set021) "4" 2) "5" 8. Mathematical set class intersection: sinter127.0.0.1:9736 > SINTER set01 set021) "1" 2) "2" 3) "3" 9. Mathematical set class union: sunion127.0.0.1:9736 > SUNION set01 set021) "b" 2) "2" 3) "1" 4) "5" 5) "3" 6) "4" 7) "a" above are all the contents of this article "how to use Redis set Set". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report