When writing another article (link), the filter function is involved. Have not been contacted before, finishing as follows.
The main references are two articles:
http://blog.csdn.net/u011510825/article/details/51859656
Http://redis.io/commands/scan
The experiment is as follows:
$ redis-cli-h [host]-P8379> smembers myset 1)" One"2)" Both"> Sscan myset o*(Error) ERR Invalid cursor> Sscan MySet0Match o* 1) "0" 2)1)" One"> Sscan MySet0Match *1)"0"2)1)" One" 2)" Both"> Sscan MySet0Match * Count1 1) "2" 2)1)" One"> Sscan Myset10Match"{' I ': ' [1-9][0-9][0-9]* '}"1)"0"2)1)"{' I ': ' 990 ', ' i2 ': ' 991 '}"
There are a few things to explain above.
1. The command to get set requires the use of smember. For more command List reference:
Http://www.runoob.com/redis/redis-sets.html
Redis Collection commands The following table lists the Redis collection basic commands: Ordinal commands and Descriptions1sadd key Member1 [member2] adds one or more members to the collection2SCard Key Gets the number of members of the collection3Sdiff key1 [Key2] Returns the difference set for all sets given4sdiffstore Destination Key1 [Key2] Returns the difference set for all sets and is stored in destination5SINTER key1 [Key2] returns the intersection of all sets given6sinterstore Destination Key1 [Key2] returns the intersection of all sets given and stored in destination7Sismember Key member determines whether the member element is a member of the collection key8smembers Key returns all members in the collection9smove Source Destination member moves the member element from the source collection to the destination collectionTenSPOP key to remove and return a random element from the collection Onesrandmember Key [count] returns one or more random numbers in the collection Asrem Key Member1 [member2] removes one or more members from the collection -sunion key1 [Key2] Returns the set of all the given sets -sunionstore Destination Key1 [Key2] The aggregation of all given collections is stored in the destination collection thesscan key cursor [MATCH pattern] [count count] elements in the iteration collection
2. You can see the return result of Sscan, there are two parts, the first part is a number, basically 0, sometimes positive. The second part is the result.
In fact, the first part represents a cursor. Scan is based on a cursor, each time using scan (including Sscan), starting with cursor 0, and then the command will return a new cursor, if the new cursor is not 0, indicating that the traversal is not finished, to use the new cursor as a parameter, continue to input to obtain the subsequent results.
For example, when the following Count 1, the traversal does not end, it will return a non-0 cursor. Subsequent use of the new cursor to run the command.
>smembers MySet1)" One"2)" Both"> Sscan MySet0Match * Count11)"2"2)1)" One"> Sscan MySet2Match * Count11)"3"2)1)" Both"> Sscan MySet3Match * Count11)"0"2) (Empty list orSet)
An explanation of the official website can be viewed here:
Http://redis.io/commands/scan
The Redis filter (SCAN) feature