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

Brief introduction of set type data operation instruction in redis database

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly explains "Introduction to redis database set type data operation instructions". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian slowly and deeply to study and learn "Introduction to redis database set type data operation instructions" together!

sadsadd key member Adds a string element to the key set, returns 1 if successful, if the element and

0 is returned in the set, and an error is returned if the set corresponding to the key does not exist.

srem key member removes the specified element from the set corresponding to key, successfully returns 1, if member is not in the set

If key exists or does not exist, return 0. If key does not correspond to a value of set type, return error.

spop key deletes and returns a random element in the set corresponding to key, if the set is empty or key does not exist, returns

nil。

srandmember key is the same as spop, randomly taking an element from the set, but not deleting the element.

move srckey dstkey member Remove member from srckey set and add to dstkey set,

The whole operation is atomic. Success returns 1, if member does not exist in srckey returns 0, if key is not set

Type return error.

scard key Returns the number of elements in a set, 0 if set is empty or key does not exist.

sismember key member Judge whether member exists in the set, return 1, 0 means does not exist or key does not exist

Existence.

sinter key1 key2 … keyN Returns the intersection of all given keys.

sinterstore dstkey key1 ....... keyN Returns the intersection of all given keys and saves the intersection to dstkey.

sunion key1 key2 ...... keyN Returns the union of all given keys.

sunionstore dstkey key1 ...... keyN Returns the union of all given keys and saves the union under dstkey.

sdiff key1 key2 ...... keyN Returns the difference set of all given keys.

sdiffstore dstkey key1 ...... keyN Returns the difference set of all given keys and saves the difference set to dstkey.

smembers key returns all elements of the set corresponding to the key, the result is unordered. Thank you for reading, the above is the "redis database set type data operation instruction introduction" content, after the study of this article, I believe that we have a deeper understanding of the redis database set type data operation instruction introduction, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

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

Servers

Wechat

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

12
Report