redis three Summary - Data type

redis There are five main types of data

  1. String

  A key value corresponding to a

  This data type is binary, it is safe, you can save any data set stored images and data objects

    You can save a maximum key size 512M of value

       Example:

  Structured as follows:

 

 

      2. Hash

  A collection of key-value pairs

        A string field type and value of the mapping table, Hash particularly suited for storing objects

Each hash can store two 32  -1 key-value pair (40 million)

Example:

Data is structured as follows:

       

     A type somewhat similar to the object hash table, the properties of the object stored in the object table (Field), and a value corresponding to the attribute (value)

     3. List

  Redis list is a simple list of strings, sort insertion order, you can add an element to the head of the list (left) or tail (right)

  List can store up to 2 32  - 1 element (4,294,967,295, each list can store more than 4 billion).

  Example:

       

 

  The list is structured as follows

   

   4. collection

    Redis is a string Set the type of 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 2 32  - 1 (4,294,967,295, each set can store 40 million members).

    Value set is not repeated, the value of the set filling existing, is not added into the

    Example:

    

            Collection structure is as follows:

      

  5. ordered set

    Redis zset and is set as a collection of elements of type string, and does not allow duplicate members, add members that already exists, it is not added into the operation fails

    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.

     Example:

    Structured as follows:

     

  About five or more data types to sum up:

Collections and ordered collection of the same point: Duplicate elements are not allowed; different points: (1) an ordered set, as long as the member name can not be repeated, the members may have the same score; (2) an ordered set based on the score values ​​are sorted, and the uncertain element in the set position after the insertion occurs in the collection.

Listing and comparing the set: After the collection insert elements, regardless of the order of the position of insertion of the element in the collection Structurally, the list lpush elements appear in the top of the list, RPUSH elements appears at the bottom of the list, the list can be repeated insertion of existing elements, but rather a collection of fail

 

Guess you like

Origin www.cnblogs.com/xmnote/p/11289673.html