Preface
As a bald person of code at this time, he is definitely no stranger to Redis. If you haven't used Redis, I'm really embarrassed to go out for an interview, maybe how many times I have been hanged by the interviewer.
After all, Internet companies and some startups now use Redis, such as Amazon, Google, Ali, and Tencent. It shows that it is really necessary to be proficient in the use of Redis.
Therefore, today, I shared the "redis depth notes" coded by Tencent Cloud. The content of the notes did not say a word of nonsense. The whole article is the essence of it!
If you need the help of a small partner who needs the PDF version of Redis Deep Notes, you can get it for free by adding a small assistant VX (gyhycx7980) as shown in the picture below!
PART1: Redis in-depth notes opening
1. What can Redis be used for?
- Thoughts from the Redis interview
- What can Redis do?
2.Redis basic data structure
- Redis installation
- Redis basic data structure
- General rules for container data structures
- Some thoughts on the use of Redis
If you need the help of a small partner who needs the PDF version of Redis Deep Notes, you can get it for free by adding a small assistant VX (gyhycx7980) as shown in the picture below!
PART2: Summary of the application of Redis
1. Distributed lock
- Distributed lock
- Timeout problem
- Reentrancy
2. Delay queue
- Asynchronous message queue?
- What if the queue is empty?
- Queue delay
- Idle connections are automatically disconnected
- Lock conflict handling
- Implementation of Delay Queue
- further optimization
3. Bitmap
- Basic use
- Statistics and lookup
- Magic instruction bitfield
4.HyperLogLog
- Instructions
- What does pf pf mean?
- What occasions is pfmerge suitable for?
- Precautions
- HyperLogLog implementation principle
- Why is the memory usage of pf 12k?
5. Bloom filter
- What is a Bloom filter?
- Bloom filter in Redis
- Basic use of Bloom filter
- Precautions
- Principle of Bloom filter
- Space occupancy estimate
- How will the false positive rate change when the actual element exceeds?
- What should I do if Redis4.0 is not available?
- Other applications of Bloom filters
6. Simple current limit
- How to use Redis to implement a simple current limiting strategy?
7. Funnel current limit
- Redis-Cell
- Some thinking
8.GeoHash
- Use the database to count people nearby
- GeoHash algorithm
- The basic use of Redis Geo instructions
9.Scan
- Basic use of scan
- The structure of the dictionary
- scan traversal order
- Dictionary expansion
- Compare the traversal sequence before and after expansion and contraction
- Progressive rehash
- More scan instructions
- Big key scan
If you need the help of a small partner who needs the PDF version of Redis Deep Notes, you can get it for free by adding a small assistant VX (gyhycx7980) as shown in the picture below!
PART3: Principles of Redis
1. Thread IO model
- Non-blocking IO
- Event polling (multiplexed)
- Instruction queue
- Response queue
- Timed task
2. Communication protocol
- RESP(Redis Serialization Protocol)
- Client -> Server
- Server -> Client
3. Endurance
- Snapshot principle
- fork (multi-process)
- AOF principle
- AOF rewrite
- fsync
- Operation and maintenance
- Redis4.0 hybrid persistence
4. Pipeline
- Redis message interaction
- Pipeline pressure test
- Deeply understand the nature of pipelines
5. Affairs
- Basic use of Redis transactions
- Atomicity
- discard
- optimization
- Watch
6.PubSub
- Message multicast
- PubSub
- Mode subscription
- Message structure
- Disadvantages of PubSub
7. Small object compression
- 32bit vs 64bit
- Compressed storage of small objects (ziplist)
- Memory reclamation mechanism
- Memory allocation algorithm
8. Master-slave synchronization
- CAP principle
- Eventually unanimous
- Master-slave synchronization
- Incremental synchronization
- Snapshot synchronization
- Add slave node
- Diskless copy
- Wait instruction
If you need the help of a small partner who needs the PDF version of Redis Deep Notes, you can get it for free by adding a small assistant VX (gyhycx7980) as shown in the picture below!
PART4: Redis cluster
1.Sentinel
- Message is lost
- Sentinel basic use
2.Codes
- Codis fragmentation principle
- How to synchronize the slot relationship between different Codis instances?
- Expansion
- Automatic equalization
- The price of Codis
- Advantages of Codis
- Operation process of MGET instruction
- Architecture changes
- Codis's embarrassment
- Codis background management
3.Cluster
- Slot location algorithm
- Jump
- migrate
- Fault tolerance
- Network jitter
- Possibly offline (PFAIL-Possibly Fail) and confirmed offline (Fail)
- Basic use of Cluster
- Slot migration awareness
- Cluster change awareness
If you need the help of a small partner who needs the PDF version of Redis Deep Notes, you can get it for free by adding a small assistant VX (gyhycx7980) as shown in the picture below!
PART5: Redis expansion
1.Stream
- Message ID
- Message content
- Additions, deletions, modifications
- Independent consumption
- Create consumer group
- consumption
- What if there are too many Stream messages?
- What happens if the message forgets the ACK?
- How does PEL avoid message loss?
- Stream's high availability
- Partition
2.Info instruction
- How many instructions does Redis execute per second?
- How many clients are connected to Redis?
- How much memory does Redisn take up?
- How big is the copy backlog buffer area?
3. Talk about distributed locks again
- Redlock algorithm
- Redlock usage scenarios
4. Expiration strategy
- Expired key collection
- Timed scanning strategy
- Expiration policy from library
5.LRU
- LRU algorithm
- Approximate LRU algorithm
6. Lazy delete
- Why does Redis need to be lazy free?
- flush
- Asynchronous queue
- AOF Sync is also very slow
- More asynchronous delete points
7. Use Jedis gracefully
- Retry
8. Protect Redis
- Command security
- Port security
- Lua script security
- SSL proxy
9. Redis secure communication
- spiped principle
- Getting started with spiped
If you need the help of a small partner who needs the PDF version of Redis Deep Notes, you can get it for free by adding a small assistant VX (gyhycx7980) as shown in the picture below!
PART6: Source code
1. Explore the internal structure of strings
- embstr vs raw
- Expansion strategy
2. Explore the interior of the dictionary
- dict internal structure
- Progressive rehash
- Find process
- hash function
- hash attack
- Expansion conditions
- Shrinkage condition
- structure of set
3. Explore the inside of the compressed list
- Add elements
- Cascade update
- IntSet small integer set
4. Explore the inside of the quick list
- How many elements are stored in each ziplist?
- Compression depth
5. Explore the internal structure of the jump list
- basic structure
- Find process
- Random layers
- Insertion process
- Delete process
- Update process
- What if the score values are the same?
- How is the element ranking calculated?
6. Explore the inside of the compact list
- Cascade update
- Replace ziplist
7. Explore the inside of the radix tree
- application
- structure
- Add and delete nodes
to sum up
Finally, what I want to say is that learning is not difficult, and it is perseverance, especially after we participate in work, it is even more difficult to continue to persevere in learning. But for programmers, learning is the foundation of a career. If you give up learning, it will be sooner or later to be eliminated by the market. Therefore, learning more new knowledge is a greater investment for yourself.
That's it, that's it.
If you need the help of a small partner who needs the PDF version of Redis Deep Notes, you can get it for free by adding a small assistant VX (gyhycx7980) as shown in the picture below!