]>
Commit | Line | Data |
---|---|---|
8fb13ce8 | 1 | |
2 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> | |
3 | <html> | |
4 | <head> | |
5 | <link type="text/css" rel="stylesheet" href="style.css" /> | |
6 | </head> | |
7 | <body> | |
8 | <div id="page"> | |
9 | ||
10 | <div id='header'> | |
11 | <a href="index.html"> | |
12 | <img style="border:none" alt="Redis Documentation" src="redis.png"> | |
13 | </a> | |
14 | </div> | |
15 | ||
16 | <div id="pagecontent"> | |
17 | <div class="index"> | |
18 | <!-- This is a (PRE) block. Make sure it's left aligned or your toc title will be off. --> | |
19 | <b>Sets: Contents</b><br> <a href="#Redis Set Type">Redis Set Type</a><br> <a href="#Implementation details">Implementation details</a> | |
20 | </div> | |
21 | ||
22 | <h1 class="wikiname">Sets</h1> | |
23 | ||
24 | <div class="summary"> | |
25 | ||
26 | </div> | |
27 | ||
28 | <div class="narrow"> | |
29 | #sidebar <a href="SetCommandsSidebar.html">SetCommandsSidebar</a><h1><a name="Redis Set Type">Redis Set Type</a></h1>Redis Sets are unordered collections of <a href="Strings.html">Redis Strings</a>. It's possible to add, remove, and test for existence of members in O(1).<br/><br/>Redis Sets have the desirable property of not allowing repeated members. Adding the same element multiple times will result in a set having a single copy of this element. Practically speaking this means that adding an members does not require a "check if exists then add" operation.<br/><br/>Commands operating on sets try to make a good use of the return value in order to signal the application about previous existence of members. For instance the <a href="SaddCommand.html">SADD</a> command will return 1 if the element added was not already a member of the set, otherwise will return 0.<br/><br/>The max number of members in a set is 232-1 (4294967295, more than 4 billion of members per set).<br/><br/>Redis Sets support a wide range of operations, like union, intersection, difference. Intersection is optimized in order to perform the smallest number of lookups. For instance if you try to intersect a 10000 members set with a 2 members set Redis will iterate the 2 members set testing for members existence in the other set, performing 2 lookups instead of 10000.<h1><a name="Implementation details">Implementation details</a></h1>Redis Sets are implemented using hash tables, so adding, removing and testing for members is O(1) in the average. The hash table will automatically resize when new elements are added or removed into a Set.<br/><br/>The hash table resizing is a blocking operation performed synchronously so working with huge sets (consisting of many millions of elements) care should be taken when mass-inserting a very big amount of elements in a Set while other clients are querying Redis at high speed.<br/><br/>It is possible that in the near future Redis will switch to skip lists (already used in sorted sets) in order to avoid such a problem. | |
30 | </div> | |
31 | ||
32 | </div> | |
33 | </div> | |
34 | </body> | |
35 | </html> | |
36 |