In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the knowledge points that must be mastered in learning redis. What is introduced in this article is very detailed and has a certain reference value. Friends who are interested must finish reading it!
The eight things you must know about redis are as follows:
1. What is redis
Redis is a storage system that supports multiple data structures such as Key-Value. Can be used for caching, event publishing or subscribing, high-speed queuing and other scenarios. The database is written in ANSI C language, supports network, provides string, hash, list, queue, set structure direct access, memory-based, persistent.
2. Supported languages
3. What are the application scenarios of redis
1, session caching (most commonly used)
2, message queuing
For example, pay 3, activity ranking or counting
4, publish, subscribe to messages (message notification)
5, product list, comment list, etc.
4. Redis data type
Redis supports a total of five data classes: string (string), hash (hash), list (list), set (collection) and zset (sorted set ordered collection).
(1) string (string)
It is the most basic data type of redis, a key corresponds to a value, it should be noted that it is a key value maximum storage 512MB.
(2) hash (hash)
Redis hash is a collection of key-value pairs, a mapping table of field and value of string type, suitable for storing objects.
(3) Table (list)
Is a simple list of strings for redis that sorts in the order in which they are inserted
(4) Group (collection)
Is an unordered collection of string types and cannot be repeated
(5) zset (sorted set ordered set)
Is an ordered collection of string types and cannot be repeated
Each element in an ordered set needs to specify a score, and the elements are sorted in ascending order according to the score. If multiple elements have the same score, they are sorted in ascending order in dictionary order, so sorted set is very suitable for ranking.
5. Redis service-related commands
Slect# Select Database (Database number 0-15)
Exit # exit connection
Information # Information and statistics on access to services
Monitor# real-time monitoring
Config get# gets service configuration
Flushdb# deletes key from the currently selected database
Flushall# deletes keys from all databases
6. Publish and subscribe to redis
Redis publish and subscribe (publish / subscribe) is one of its message communication mode, one party sends information, the other party receives information.
The following picture shows three clients subscribing to the same channel at the same time.
The following figure shows that when new information is sent to Channel 1, the message is sent to the three clients that subscribe to it.
7 persistence of Redis
There are two ways to persist redis: snapshots (snapshots) and append files only (AOF)
Snapshot (snapshot)
1. Write the data stored in memory to the binary file as a snapshot, such as in the default dump.rdb
2, save 900 1
If more than one Key is modified within 900 seconds, start the snapshot save
3, save 300 10
If more than 10 Key are modified within # 300 seconds, start snapshot save
4, save 60 10000
# if more than 10000 key points are modified within 60 seconds, start snapshot save
Attach only files (AOF)
1. When using AOF persistence, the service appends each write command received to the file (appendonly.aof) through the write function.
2 description of the parameters of the persistent storage mode of Magi AOF
Appendonly yes # enable AOF persistent storage mode appendfsync always # writes to disk immediately after receiving the write command, the efficiency is the worst, the effect is the best, appendfsync everysec # writes to disk once per second, efficiency and effect are in the middle, appendfsync no # completely depends on the operating system, the efficiency is the best, and the effect cannot be guaranteed.
Performance test of 8pr redis
Bring your own related testing tools
The actual test executes 1 million of the requests at the same time
The above are all the contents of this article "what are the knowledge points you must master to learn redis?" Thank you for your reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.