HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
Redis is an unordered collection of Set string type. It is the only member of the collection, which means that the collection can not duplicate data.
Redis is set by the hash table to achieve, so add, delete, find the complexity is O (1).
Set the maximum number of members 232--1 (4294967295 Each set can store more than 40 million members).
redis 127.0.0.1:6379> SADD w3resourcekey redis (integer) 1 redis 127.0.0.1:6379> SADD w3resourcekey mongodb (integer) 1 redis 127.0.0.1:6379> SADD w3resourcekey mysql (integer) 1 redis 127.0.0.1:6379> SADD w3resourcekey mysql (integer) 0 redis 127.0.0.1:6379> SMEMBERS w3resourcekey 1) "mysql" 2) "mongodb" 3) "redis"
In the example above weSADD command to the collection named w3resourcekey insertion of three elements.
The following table lists the Redis set of basic commands:
No. | Command and description |
---|---|
1 | SADD key member1 [member2] Add one or more members to the collection |
2 | SCARD key Being members of a collection |
3 | SDIFF key1 [key2] Returns the difference between the set of all collections |
4 | SDIFFSTORE destination key1 [key2] Returns the difference set all set and stored in the destination |
5 | SINTER key1 [key2] Back to the intersection of a given set of all |
6 | SINTERSTORE destination key1 [key2] Returns the intersection of all sets and stored in the destination |
7 | SISMEMBER key member Determining whether the element is a member of a collection of key members |
8 | SMEMBERS key Returns a collection of all the members of the |
9 | SMOVE source destination member The member elements from source to destination mobile collection set |
10 | SPOP key Removes and returns a random element in the collection |
11 | SRANDMEMBER key [count] Returns a collection of one or more random number |
12 | SREM key member1 [member2] Remove the set of one or more members |
13 | SUNION key1 [key2] Back to all given set of union |
14 | SUNIONSTORE destination key1 [key2] All the given set and stored in the destination set collection |
15 | SSCAN key cursor [MATCH pattern] [ COUNT count] Iterative elements in the collection |