In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what is the function of Redis memory database". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the role of Redis memory database".
Redis is an in-memory data structure storage system that can be used as database, cache, and message middleware.
It supports many types of data structures, string (strings), hash (hashes), list (lists), set (sets), ordered set (sorted sets) and range query, bitmaps, hyperloglogs and geospatial (geospatial) index radius query.
Redis has built-in replication (replication), LUA script (Lua scripting), LRU driven event (LRU eviction), transaction (transactions) and different levels of disk persistence (persistence), and provides high availability (high availability) through Redis Sentinel (Sentinel) and automatic partitioning (Cluster).
Redis is a TCP service based on client-server model and request / response protocol.
1 Pub/Sub message subscription
The client sends out a subscribed channel name: SUBSCRIBE foo bar, and messages sent to these channels by other clients will be pushed to all subscribed clients.
2 memory optimization
In Redis2.2 version and beyond, memory compression technology will be used when storing collection data.
To store more data with less memory, such as Hashes,Lists,Sets and Sorted Sets
When all the numbers in these sets are less than a given element, and the number of elements in the set is less than a certain value, the stored data is encoded in a very memory-saving way. theoretically, using this coding will save at least 10 times more memory (an average of 5 times more memory savings). And this coding technology is transparent to users and redis api. Because we use CPU for memory, we provide a way to change the threshold by modifying it in redis.conf. Memory recovery strategy: LRU is the only method supported by Redis to recycle the least used keys
3 transaction
A transaction is an atomic operation: either all or none of the commands in the transaction are executed.
The EXEC command is responsible for triggering and executing all commands in the transaction.
When using AOF for persistence, Redis writes the transaction to disk using a single write (2) command, and if Redis finds such a problem with the AOF file when restarting, it exits and reports an error
This problem can be fixed by using the redis-check-aof program, which removes information about incomplete transactions in the AOF file, ensuring that the server starts smoothly.
When the DISCARD command is executed, the transaction is abandoned, the transaction queue is emptied, and the client exits from the transaction state
4 redis distributed lock
Distributed locks are very useful primitives in many scenarios, and different processes must share resources by monopolizing resources.
Redis can handle up to 232 keys and has been tested in practice. Each instance stores at least 250 million keys, and any list, set, and sorted set can hold 232 elements.
Redis uses default asynchronous replication, which is characterized by low latency and high performance. A master can have multiple slave
5 persistence
When RDB saves the RDB file, the only thing the parent process needs to do is to fork a child process, and all the subsequent work is done by the child process, and the parent process does not need to do other IO operations, so RDB persistence can maximize the performance of redis.
Compared with AOF, the RDB approach is faster when recovering large datasets.
The AOF file is an append-only log file that can be fixed using the redis-check-aof tool. The $redis-check-aof-fix,AOF file sequentially saves all writes performed to the database in Redis protocol format
6 Common commands:
Link cluster
Redis-cli-h 0.0.0.0-p 6031-c-a password
Query cluster node information
Redis-cli-h 0.0.0.0-p 7000 cluster nodes
Add Cluster Node
. / redis-trib.rb add-node 127.0.0.1:7006 127.0.0.1:7000
Remove nod
. / redis-trib del-node 127.0.0.1VR 7000 ``
Thank you for your reading, the above is the content of "what is the role of Redis memory database". After the study of this article, I believe you have a deeper understanding of what the role of Redis memory database is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.