5 Redis data types and scenarios

Redis stands for Remote Dictionary Server, a Key-Value type memory database Essentially, the entire database in memory to load all of them operate on a regular basis by the asynchronous operation of the database data to the hard line Flush preservation. Because pure memory operation, the Redis very good performance, can read and write per 10w, is the fastest known performance Key-Value DB. In addition Redis supports saving multiple data structures, the maximum limit of a single value is 1GB, it can be used to implement many useful features. For example, with the List to achieve FIFO doubly linked list to achieve a lightweight, high-performance message queuing service; set can do high-performance tag systems. In addition Redis can also set expire time of deposit of key-value. But the disadvantage is the database Redis limited capacity easily house the memory, reading and writing can not be used as high-performance mass data, so Redis appropriate scene mainly confined to the small amount of data and high-performance computing operations.

Five data types

  • String String: binary safe and can contain any data, such as JPG images or later serialized object, is the most basic type of data, a key can store a maximum 512MB. Format set key value
  • Hash Hash: is a collection of key-value pairs. Type field is a string value and a mapping table, hash particularly suitable for storing objects. Format: hmset name key1 value1 key2 value2
  • List List: list is a simple list of strings, sort insertion order, an element may be added to the head or tail of the list.

   Format: Ipush name value corresponding to the head of the list in the key string element is added

   Format: rpush name value corresponding to the list of elements in the key tail add the string

  • set collection: string type is an unordered collection. Collection is achieved through a hash table, so add, delete, search complexity is O (1). Format: sadd name value
  • zset ordered collection: a collection of type string elements must be unique. Each element will be associated with a type of double scores, Redis from small to large sort of ensemble members through this score.

 

Guess you like

Origin www.cnblogs.com/wangyongwen/p/11487354.html