redis supported data types

1, string (string)

  And memcached as a value corresponding to a key, the key value of the maximum storage 512MB, the maximum value of the stored value is also 512MB. The string type is binary safe. Redis meaning of string can contain any data. Such as jpg image or serialized object. Use set and get commands to SET and GET.

  Command [SET key value] [GET key]

2, hash (hash)

  Key (key => value) pairs. Field is a string type and the value of the mapping table, hash is particularly suited for storing objects (may be stored for each hash key 2 ^ 32 -1 to (40 million)). Use set and get commands to HMSET, HGET.

  命令为【HMSET key key1 value1 key2 value2】【HGET key key1】

3, list (list)

  List is a simple list of strings, sort insertion order. You can add an element to the head or tail of the list (the list can store up to 2 ^ 32 - The 1 element (4,294,967,295 each list can store 40 million)). LPUSH or feed value command RPUSH, to obtain the value of the command LRANGE.

  [Command] [LPUSH key value LRANGE key 0 10] to obtain a list of key from the left 0-10 value.

4, set (collection)

  Set string type is an unordered collection. Collection is achieved through a hash table, so add, delete, search complexity is O (1). The maximum number of members in the set of power 32 - 2 1 (4,294,967,295, each set can store 40 million members). SADD set to add a string element corresponding to the set key, a successful return, if the element has been returned in the collection 0.

  [Command] [SADD key value SMEMBERS key]

5, zset (ordered set)

  And also set the same set of string type elements, and does not allow duplicate members. The difference is that a double score will be associated with each type of element. It is to redis from small to large order of collection of member passing score. zset member is unique, but the score (score) it can be repeated. ZADD add elements to the collection, then updates the corresponding element is present in the set score.
  [Command] [ZADD key score value ZRANGEBYSCORE key 0 100]

Note: all types have many other key commands, not elaborated on here.

 

 

Guess you like

Origin www.cnblogs.com/smallzhen/p/11973628.html