3. List 4. Set 5. Zset (sorted set) 6. Cardinality String String is the most basic redis type. You can think of it as Memcached, with a value for each key. The string type is binary safe. The redis string can contain any data. Like JPG images or serialized objects. The string type is the most basic Redis data type. A Redis string value can be a maximum of 512 Hash values. Redis hash is a mapping table of fields and values of string type. Hash is especially suitable for storing objects. A Redis List is a simple List of strings, sorted by insertion order. You can add an element to the head (left) or tail (right) of the list, and the bottom of it is actually a linked list Set. The Set of Redis is an unordered Set of strings. It is a sorted set implemented via a HashTable implementation. Redis Zset, like set, is a collection of string elements and does not allow duplicate members. The difference is that each element is associated with a double score. Redis uses scores to sort the members of a collection from smallest to largest. Members of a Zset are unique, but scores can be repeated. Command address:
redisdoc.com/Redis key (key) 1. keys * 2. exists key name, determine whether a key exists 3. Move key db –> current library does not exist, removed 4. Set the TTL key to expire in seconds. -1 indicates that the key will never expire. -2 indicates that the key has expired, that is, it has been deleted

String: A String is the most basic data structure of Redis. It is stored in a Java-like Map structure inside Redis with a key and a value

Basic commands:

Commands that support simple operations:

Here is the code test flow:

Getrange /setrange Getrange: Obtains a value within a specified range, for example, between…… 0-1: indicates all setrange values within a specified range. The format is setrange key value. The value is changed from the original value of the string to a certain position

Setex (Set with expire) keysecond value /setnx(Set if not exist) SEtex: Sets the key with expiration time dynamically. Setex key second value True value setnx: Sets the key value only if the key does not exist.

Mset /mget/msetnx mset: Sets one or more key-value pairs at the same time. Mget: Gets all (one or more) of the values of a given key. Msetnx: Sets one or more key-value pairs simultaneously, if and only if none of the given keys exist. Otherwise it will not take effect

The List structure is a common structure in Redis, it can store multiple strings, and it is ordered Redis List is bidirectional,

Using a linked list structure means a loss of read performance. The linked list can only traverse nodes in one direction. Advantage: The convenience of inserting and deleting linked list data nodes is allocated in different memory domains, not contiguity

Thus, the use of the linked list structure is scenario-sensitive, and it is very convenient for list data that often needs to be inserted and deleted, because it can be inserted and deleted without moving other nodes. It does not perform well for those that need to be searched frequently, and can only be searched and compared from left to right or right to left.

Lpush /rpush/lrange Lpush: insert from the left side of the list rpush: insert from the right side of the list lrange: view the node values of the list lrange list start end End =-1 indicates all

Lpop/RPOP LPOP: delete the first node on the left and return it to RPOP: delete the first node on the right and return it

Lindex: gets elements by index subscript (from top to bottom) lindex: gets elements in a list by index from zero

Llen evaluates the length of the list and returns the length

Lrem key delete N * delete 2 elements with values equal to v1 from left to right, return the actual number of deleted elements * lrem list3 0, indicating that all the given values are deleted. Zero is the total number of lREM list nodes

Ltrim Key start index End index, truncate the specified range of values and assign the value to key Ltrim: Truncated elements from a specified index range in the format of ltrim list key start index End index The truncated elements are saved in the original list, starting at 0 by default

Rpoplpush source list destination list removes the last element of the list and adds it to another list and returns the last element removed from the source list and left inserted into the destination list

Lset Key Index Value Changes the value of the index

Linsert key before/after value 1 Value 2 Inserts value 2 before/after value 1

It is a linked list of strings, left and right can be inserted to add; If the key does not exist, create a new linked list; If the key already exists, add the content. If the values are removed, the corresponding keys are gone. Linked lists are extremely efficient both at the beginning and the end, but are notoriously inefficient when operating on intermediate elements.