[Daily] in using the think Redis set collection

The corporate sector needs to have a colleague, is the need for the data currently stored in another department a guide all out, all his data in the current business b guide out to take about two difference sets, the presence of a, b does not exist of down, I am going to call an interface to delete the corresponding files. I feel this can be used to operate a set of redis, but considering the amount of data is particularly large, file has 200G, it estimated that memory is not enough, not yet know Zezheng.


The method of operation set redis
sADD to add one or more members set inside
sCard, sSize acquired about the number of members in the set of
sDiff in Comparative travel set of N set
sDiffStore and sDiff similar, but the result is stored in a first set of difference a key inside
sInter return multiple sets of the intersection
sInterStore and sInter similar, the result is stored in the first key inside
sIsMember, sContains check whether the parameter is a member of the set of a
sMembers, sGetMembers get all members of the collection
sMove the collection member moves from one set to another set
sPop remove a randomly obtained in the collection and the member
sRandMember obtaining a random collection member, it does not remove
sRem, sRemove remove the specified collection member
sUnion plurality of return set and set
sUnionStore and the plurality of sets of key set stored in the first parameter which

Because the set is redis implemented using a hash table, and therefore is disordered, and the individual elements are determined and efficient process. Can be seen when the processing is performed a plurality of members, the time complexity is O (N), of the individual members to find other process determines whether there is deleted, the time complexity is O (1)

sPop sRandMember, which can be removed in a random value may be set at a lottery scenario
union intersection difference set, it can be used in a large number of relatively high real-time data collection operations to take


When a large amount of data required for a set of operations, such as determining whether demand exists, Bloom filter can be used
Bloom filter can be understood as a very precise set structure, when you use a method of determining it contains whether the object exists, it may be false. However, Bloom filter is not particularly precise, as long as a reasonable set of parameters, it is relatively sufficient accuracy can be controlled accurately, there will only be a small probability of false positives.

When the Bloom filter say that there is a value that may not exist; when it say there, it certainly does not exist
primarily to solve large-scale data does not require precise filtering scenarios, such as checking e-mail address is spam, reptile URL address to re-address the cache penetration problems.


Look online articles have said in memory exceeds the specified value, redis failure data will be deleted, and this time will be sADD report timeout, this situation because I have not encountered such a scene, I have not seen.

View redis memory size:
redis-cli
info Memory

Guess you like

Origin www.cnblogs.com/taoshihan/p/11717026.html