As Java Developers 【Redis】 It's the knowledge you have to master
Redis It is the most widely used storage Middleware in the field of Internet technology , It is 「Remote Dictionary Service」 An acronym for , That is to say 「 Remote Dictionary Service 」.Redis With its ultra-high performance 、 Perfect documentation 、 The simple and easy to understand source code and rich client library support are widely praised in the field of open source middleware .
Many large Internet companies at home and abroad are using Redis, such as Twitter、YouPorn、 Blizzard Entertainment 、Github、StackOverflow、 tencent 、 Ali 、 JD.COM 、 Huawei 、 Sina Weibo and so on , Many small and medium-sized companies also have applications . It can also be said that , Yes Redis At present, the understanding and application practice of middle and advanced back-end developers have become indispensable skills .
This paper is divided into 3 Parts right Redis Conduct “ The anatomy of the ”：
The first part is right Redis A basic introduction is given , And showed some Redis Use example of ;
The second part is right Redis A number of commands of the are described in detail , After that, I also introduced Redis Management operation and use of Redis The way to build more complex applications ;
The third part introduces how to optimize memory 、 Horizontal sectioning and Lua Script this 3 Technology to expand Redis.
If you need to get this 【Redis file 】 Please forward the document and then pay attention to my private reply “666” Get access to it ！（ More details , So give a rough introduction of the knowledge Redis）
One 、Redis introduction
Introduction ： about Redis The description of the database tells only part of the truth ,Redis yes - A very fast non relational database ( non-relational database), It can store keys (key) And 5 Different types of values ( value) Mapping between (mapping), You can persist key value pairs stored in memory to the hard disk , You can use the replication feature to extend read performance , You can also use client slicing to extend write performance , The following sections will introduce Redis These characteristics of .
Redis The table of contents is as follows
About Redis Comparison with other databases and software
The following figure shows some of the functions of Redis There are overlapping database servers and cache servers , It can be seen from this table that Redis And the difference between these databases and software .
The first part is about the detailed introduction. Because the length of the copy is too long, it is not shown in detail
Two 、Redis Core concept of
The previous chapters of this section will delve into the standard Redis command , These include Data operation command and configuration command , And the next few chapters will show how to use Redis Building more complex tools and Applications , And at the end of the day Redis To build a simple social networking site .
Redis The table of contents is as follows
- String command 、 List commands and set commands
- Hash commands and ordered set commands
- Publish and subscribe commands
- Other commands
2.2. Data security and performance assurance
- Persist data to hard disk
- Copy data to other machines
- Handling system faults
- Redis Business
- Non transactional pipeline ( non-transactional pipeline )
- Diagnose performance problems
2.3. Use Redis Build support
- Use Redis Log
- Use Redis Implement the counter and make statistics
- Inquire about IP The city and country of the address
- Service discovery and configuration
2.4. Use Redis Build application components
- Build two prefix matching auto completion programs
- Improve performance by building distributed locks
- Control concurrency by developing counting semaphores
- Build two task queues for different purposes
- Delay message delivery through message pull system
- Learn how to distribute documents
2.5. Search based applications
- Use Redis To search
- Sort the search results
- Achieve advertising orientation
- Realize position search
2.6. Build a simple social network
- Users and status
- Home timeline
- List of followers and being followed
- Publishing and deleting status messages
- flow API
3、 ... and 、Redis Advanced content
The last few chapters will focus on Redis Users often encounter - Some questions to introduce ( Reduce memory usage 、 Expansion performance 、 Use Lua Language for script programming ), And explain how to use conventional technology to solve these problems .
The table of contents is as follows ：
3.1. Reduce memory usage
Short structure ( short structure )、 Slice structure ( shared structure )、 Package and store binary bits and bytes
This article will introduce 3 A very valuable reduction Redis How to use memory . Reduce Redis Can help reduce the time required to create and load snapshots 、 Lift people AOF File and rewrite AOF Efficiency of documentation 、 Reduce the time required to synchronize from the server ”, And can make Redis Store more data without adding extra hardware .
3.2. Expand Redis
Extended read performance 、 Expand write performance and memory capacity 、 Expand complex queries
With Redis More and more , Use only one Redis Sooner or later, the problem that the server can't store all the data or process all the read and write requests will appear , At this point, we need to use some methods to deal with Redis Expand , Let it meet our needs .
The extended performance diagram is as follows ：
3.3.Redis Of Lua scripting
Don't write C Add new features in case of code 、 Use Lua Override locks and semaphores 、 remove WATCH/MULTI/EXEC Business 、 Use Lua Fragment the list
The previous section describes how to build - Some tools and apply them to existing programs , At the same time, it also introduces - Technologies that can be used to solve all kinds of problems . this - - What Zhang wants to do is similar , And the effect will be better than you think .Redis from 2.6 The version began to attract people Lua Programming language for server-side script programming function , This feature allows users to directly Redis Internal execution of various operations , So as to simplify the code and improve performance .
Redis Of Lua The script is as follows ：
Redis Practical books
If you need to get this 【Redis file 】 Please forward the document and then pay attention to my private reply “666” Get access to it ！（ More details , So the knowledge points are roughly introduced ）
本文为[Java architecture Club]所创，转载请带上原文链接，感谢