In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
# Overview of collections
Similar to the set in mathematics, the operation of the set includes adding and deleting elements, intersection and difference of multiple sets and so on.
The key in the operation is understood as the name of the collection. For example, in the Weibo application, you can put all the followers of a user in a collection and all its fans in a collection. Because redis is very humanized for the collection to provide intersection, union, difference product and other operations, so long can be very convenient to achieve such as concern, common preferences, second friends and other functions, for all the above collection operations, you can also use different commands to choose to return the results to the client or save the set to a new collection.
Qq has a social function called "friend tag". You can tag your friends, such as "Beauty", "Tuhao", "Brother" and so on. You can use the collection of redis to store each customer's tag in a collection.
# Common commands
# insert elements
127.0.0.1 6379 > sadd set1 dang # put elements into set1
(integer) 1
127.0.0.1 purl 6379 > sadd set1 linux
(integer) 1
127.0.0.1 purl 6379 > sadd set1 python
(integer) 1
127.0.0.1 purl 6379 > sadd set1 nosql
(integer) 1
# Delete elements
Srem set1 aaaa / / Delete elements
Spop set1 / / randomly take out an element and delete it
# get elements
127.0.0.1 smembers set1 6379 > get all the elements in the collection
1) "linux"
2) "nosql"
3) "python"
4) "dang"
Sismember seta aaa / / determines whether an element belongs to a collection
Srandmember seta / / randomly take out an element but do not delete it
# intersection and merge difference
Sdiff seta setb / / difference set, taking seta as the standard
Sdiffstore seta setb setc / / the difference set is stored and stored in seta.
Sinter seta setb / / find the intersection
Sinterstore seta setb setc / / intersect and store, store to seta
Sunion seta setb / / Union set
Sunionstore sete seta setb / / join and store the result in sete
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.