Redis Learning Notes

Source: Internet
Author: User
Tags redis server

1. databases in Redis are named by numbers, and the database opened by default is 0. If the program is going to switch databases while it is running, you can use the Redis Select command to open other databases, such as Select 1, if you want to switch back to the default database later, just select 0.

2. In the area of data storage, Redis follows the mainstream idea of an existing NoSQL database, that is, key as a unique identifier for data retrieval, and we can simply interpret it as a key to the index in a relational database.

3. In Redis, value is treated as a binary byte stream for storing data in any format, such as the byte stream of JSON, XML, and serialized objects, so we can also think of it as a blob type field in an RDB.

4. We can also apply some of the techniques available in Redis to use value as a key to other data

5. By default, Redis will reference the number of data modifications in the current database, and when a certain threshold is reached, a snapshot of the database will be stored on disk, which we can set by the configuration file. In general, we can also set Redis to be saved on a timed basis.

6. The string type is the most basic type of data storage in Redis, which is binary safe in Redis, which means that the type can accept data in any format, such as JPEG image data or JSON object description information. The value of the string type in Redis can accommodate up to 512M of data length.

7. Setex key seconds value. Atomicity completes two operations, one is to set the value of the key to the specified string, and set the key in the Redis server survival time (in seconds). This command is primarily used when Redis is used as a cache server.

List

1. In Redis, the list type is a list of strings sorted by insertion order. Like a regular list in a data structure, we can add new elements to their head (left) and tail (right). When inserting, if the key does not exist, Redis creates a new linked list for that key.

Conversely, if all the elements in the list are removed, the key will be removed from the database as well. The maximum number of elements that can be contained in a list is 4294967295.

2. From an efficiency perspective of element insertion and deletion, if we are inserting or deleting elements at both ends of the list, this will be a very efficient operation, even if the millions record is already stored in the linked list, and the operation can be done within a constant time. However, it is necessary to note that if an element is inserted

Or delete action is in the middle of the list, it will be very inefficient.

3. The actions in list usually start with the L (list) and the rest of the operations begin with R (rump, aft).

Redis Learning Notes

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.