Sets are unordered collections of strings. If you want to store a non-repeating set of data,.LTRIM: Intercepts elements, specifying the range of intercepts, and discarding the rest.LPOPAnd: RPOPSimilarly, this means popping an element from the head of the list (left).RPOP: POP, as many of you are familiar with, pops an element (fetch and delete), RPOP“Pops an element from the tail (right).So the command LRANGE mylist 0 -1Gets all elements (first to last). LRANGE: gets the value stored in the list for the specified index range, notably, startand stopStarting from 0, negative values are supported It starts at the tail, the first to the bottom is -1, the second to the bottom is -2, and so on.LPUSH: Adds a new element to the list header (left).RPUSH: Adds a new element to the bottom (right) of the list.The implementation is based on linked lists, so even with very large volumes of data, elements can be added to the top or bottom of the list in constant time. Communication between processes is achieved with the help of redis lists Producer-consumerMode.Ī collection of string elements sorted by insertion order.Keep track of the most recent updates that users post to social networks.EXPIRE: Specifies the expiration time of the KEY ( SETThe command can also specify an expiration time.).EXISTS: Queries whether the KEY exists.GET: Gets the value of the specified KEY.(Redis-cli will be used for all subsequent examples.) 127.0.0.1:6379> SET mykey myvalue Open redis-cli to perform a simple string operation. The Redis String type is the simplest value type associated with a Redis Key. Caches the return value of an interface, etc.This means that Redis has more and more complex data structures than traditional key-value stores, and the data structures and usage of Redis are briefly described below. Redis is not just any key-value pair store, it is actually a server that supports different types of data structures.
Root ubuntu: / home/ubuntu/docker/redis $docker exec - it redis redis - cli 127.0.0.1:6379 > Copy the code medis Note: redis is the container name specified when redis is started in the previous section: –name redis(the container ID can also be used instead). Run docker exec it redis redis-cli on the host to enter the redis client in the container. -d: Runs in the background and outputs the container ID.
Docker Hub: Docker container run \ -rm \ -name redis \ -p 6379:6379 \ -d redis:5.0 Copy the code This article uses Docker to start the Redis server. This paper describes the simple use of Redis, including the use of Docker to start Redis server, the use of Redis client, Redis common data structure and its use methods and scenarios. In short, a cache is a set of copies of the original data on the computer, bringing the data closer to the user for faster access. It usually uses the expensive but faster SRAM technology instead of DRAM technology like system main memory. The cache: The cacheReferred to as” The cacheIn its original sense, it refers to a type of RAM that has faster access speed than ordinary random access memory (RAM).
Can be used as a database, cache, and message broker.