Redis common commands

Redis data types

Some commands require a combination of data types, redis.
There are five types of data, respectively, before Redis 4.0: String (String), a hash (the hash), a list (List), set (SET), an ordered set (zset).
In version 4.0, Redis added a new a type of stream. I will not speak for the time being, the future will open new articles explain in detail.

basic knowledge:

  1. Data type does not support nested, i.e. all types of elements can be a string, and the hash is not set or ordered set.
  2. In addition to the strings, each data type commands have a beginning.
  3. Hash (h)
  4. List (l)
  5. Set (s)
  6. Ordered set (z)
  7. stream(x)

String

Redis string using Redis own implementation of a string structure called simple dynamic strings: SDS, simple dynamic string
maximum storage string Redis is 512M.
And it can be used as digital. For example incr, incrby, decr, decrby operations are carried out based on the value of the digit. We can implement a counter by incr. Or increment number generator.

Hash

Hash underlying dictionary is implemented. And it is a dictionary structure. Can be constructed: field: value of the format.
As shown below:

List

The bottom of the list is implemented using a doubly linked list. Can be achieved by queuing list.
Function can be achieved by an array list with the following command:

lindex key index 
lset key index value

rpoplpush can achieve atomically data into one or the other end of the table from its header.

set

Redis set on the same set of mathematical properties, and repeated disorder. And Redis provided diff, inter, union set of three kinds of command operations.

Ordered set

有序集合使用跳跃表实现。集合是无序的,并且值不能重复。集合这种数据类型对于很多场景是不适用的。比如说,排行榜。于是 Redis 提供了一种有序集合类型。有序集合是一个每个元素都有一个分值代表在集合中的排行的一种数据结构。如果分值相同,那么按照元素的字典序进行排序。
什么是跳跃表,可以参见这篇文章:[http://blog.jobbole.com/111731/

Guess you like

Origin www.cnblogs.com/wdy1184/p/10960919.html