In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how php implements the Set operation of Redis. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Set operation
/ / add an element to the collection, while elements that already exist in the collection are ignored. If the collection does not exist, it will be created first. If key is not a collection type, false will be returned. If the element already exists, 0 will be returned. If the insertion is successful, 1 will be returned. $ret = $redis- > sAdd ('myset',' hello'); / / returns all members of the collection. $ret = $redis- > sMembers ('myset'); / / determines whether the specified element is a member of the specified collection, returns true, otherwise returns false. $ret = $redis- > sismember ('myset',' hello'); / / returns the number of elements in the collection. $ret = $redis- > scard ('myset'); / / removes and returns a random element in the collection. $ret = $redis- > sPop ('myset'); / / returns one or more random member elements in the collection. The number and condition of the returned elements are determined by the second parameter count of the function: / / if count is positive and less than the set cardinality, the command returns an array of count elements, each with different elements. / / if count is greater than or equal to the cardinality of the collection, the entire collection is returned. / / if count is negative, the command returns an array in which elements may be repeated multiple times, and the length of the array is the absolute value of count. $ret = $redis- > sRandMember ('myset', 2); / / removes an element specified in the collection, ignoring elements that do not exist. 1 is returned for successful deletion, otherwise 0 is returned. $ret = $redis- > srem ('myset',' hello'); / / iterate over the elements in the collection. / / Parameter: key, iterator variable, matching pattern, number of elements returned each time (default is 10) $ret = $redis- > sscan ('myset', $it,' a collection, 5); / / moves the specified member from a source collection to a destination collection. Returns false if the source collection does not exist or does not contain the specified element. / / parameters: source collection, target collection, moving element $ret = $redis- > sMove ('myset',' myset2', 'aaa'); / / returns the difference between all given sets. Sets that do not exist are considered empty sets. $ret = $redis- > sDiff ('myset',' myset2', 'myset3'); / / stores the differences between all given collections in the specified destination collection. Overwrite the destination collection if it already exists. Returns the number of subtraction elements. / / Parameter: the first parameter is the target set, which stores the difference set. $ret = $redis- > sDiffStore ('myset3',' myset', 'myset2'); / / returns the intersection of all given sets, and collections that do not exist are considered empty sets. $ret = $redis- > sInter ('myset',' myset2', 'myset3'); / / stores the intersection of all given collections in the specified destination collection. Overwrite the destination collection if it already exists. Returns the number of intersection elements. / / Parameter: the first parameter is the target set, which stores the intersection. $ret = $redis- > sInterStore ('myset4',' myset', 'myset2',' myset3'); / / returns the union of all given collections. Collections that do not exist are considered empty sets. $ret = $redis- > sUnion ('myset',' myset2', 'myset3'); / / stores the union of all given collections in the specified destination collection. Overwrite the destination collection if it already exists. Returns the number of union elements. / / Parameter: the first parameter is the target collection, which stores the union. $ret = $redis- > sUnionStore ('myset4',' myset', 'myset2',' myset3'); thank you for reading! This is the end of this article on "how php implements the Set operation of Redis". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.