当前位置:网站首页>Redis learning (I)
Redis learning (I)
2022-07-03 09:14:00 【Fill your head with water】
Catalog
Redis Study ( One )
1. What is? Redis
Basic concepts
Redis It's based on key value pairs NoSql database .
Unlike many key value pair databases ,Redis The value in is yes string、hash、list、set、zset、Bitmaps、HyperLogLog、GEO And other data structures and algorithms , therefore redis It can satisfy many application scenarios , And because redis Will put all data in memory , So its read-write performance is amazing . More Than This ,redis The data in memory can also be saved to the hard disk in the form of snapshot and log , In case of power failure or failure , Data in memory will not be lost .
Besides ,redis Key expiration is also provided 、 Publish subscribe 、 Business 、 Assembly line 、Lua Additional functions such as scripts .redis The advantages of
- Fast , Because the data is in memory , Be similar to HashMap,HashMap The advantage is the time complexity of both the lookup and the operation O(1)
- Support for rich data types , Support string,list,set,sorted set,hash
- Support transactions , The operations are all atomic , Atomicity means that changes to the data are either performed in full , Or none at all
- Rich features : Available for caching , news , Press key Set expiration time , It will be deleted automatically after expiration
2. redis Application scenarios of
- cache
- For some caches to be returned to the front-end data , When there are a lot of databases sql In operation , In order to avoid every interface request to query the database , You can cache some data to redis in , This is to get data directly from memory , The speed has increased a lot .
- web End user , For login caching session data , Some of the login information is stored in session in , The cache to redis in .
- queue
- redis Provided in list Interface , This list Provides lpush and rpop, These two methods are atomic , You can insert queue elements and pop-up queue elements .
- data storage
- redis It's a non relational database , You can put redis Directly for data storage , It provides operations such as adding, deleting, modifying and checking , because redis There is a good hard disk persistence mechanism ,redis Data can be persisted to the hard disk on a regular basis , To ensure the redis Data integrity and security .
- redis Lock realizes anti brush mechanism
- redis Locks can handle concurrency issues ,redis One of the data types set type ,set Types are unordered when storing data , And each value is different , Can't repeat , In this way, you can quickly find out whether a value in an element exists , Add and delete exactly .
explain :redis The basic operation of the usage scenario will be in redis Study (3)- In the actual combat chapter .
3. redis Installation and startup
redis Installation
- ** Download address :**https://github.com/tporadowski/redis/releases
2. double-click :Redis-x64-5.0.14.msichoice “ Agree to the agreement ”, Click next to continue .
choice “ add to Redis Directory to environment variable PATH in ”, It is convenient for the system to identify automatically Redis Where is the execution file .
The port number can remain the default 6379, And choose the firewall exception , So as to ensure that the external can be accessed normally Redis service .
Set the maximum value to 100M. As an experiment and learning ,100M enough .
After installed :
redis-server.exe: Server program , Provide redis service
redis-cli.exe: Client program , Connect through it redis Service and operate
Right click “ Computer ”> choice “ management ”. Find and click in the left column “ Computer management ( Local )”> Services and Applications > service . And find it on the right Redis Service by name , Check the startup . If not started , Start it manually . Under normal circumstances , The service should be up and running properly .
Set the password ( choose ):
open redis-cli.exe
CONFIG SET requirepass "yourpassword"
or
open redis.windows.conf The configuration file // window System is with windows Of ,linux System is redis.conf
find requirepass foobared, Ahead of # Remove the number , hold foobared Change to password
for example requirepass 123456test :
open redis-cli.exe
Normal prompt entry , And display the correct port number , Indicates that the service has been started .
Password verification is required before using the service . Input “auth 020826” And return (020826 It's the password set before ).
Return to the prompt OK Indicates that the verification passed .
4. redis Basic command
start-up redis command :
./redis-server # Direct start redis, Sometimes you need to start the fixed configuration file ( Reset password ) Of redis, # for example : redis-server redis/redis.windows.conf # perhaps ./redis-server …/redis.conf
redis Service related commands
# Uninstall service : redis-server --service-uninstall # Start the service : redis-server --service-start # Out of Service : redis-server --service-stop
边栏推荐
- LeetCode 30. 串联所有单词的子串
- LeetCode 1089. 复写零
- 【点云处理之论文狂读经典版12】—— FoldingNet: Point Cloud Auto-encoder via Deep Grid Deformation
- LeetCode 715. Range module
- [point cloud processing paper crazy reading classic version 12] - foldingnet: point cloud auto encoder via deep grid deformation
- Education informatization has stepped into 2.0. How can jnpf help teachers reduce their burden and improve efficiency?
- LeetCode 241. 为运算表达式设计优先级
- LeetCode 532. K-diff number pairs in array
- Binary tree traversal (first order traversal. Output results according to first order, middle order, and last order)
- 2022-2-13 learn the imitation Niuke project - Project debugging skills
猜你喜欢
Discussion on enterprise informatization construction
Binary tree sorting (C language, char type)
Gaussian elimination acwing 883 Gauss elimination for solving linear equations
干货!零售业智能化管理会遇到哪些问题?看懂这篇文章就够了
Tree DP acwing 285 A dance without a boss
状态压缩DP AcWing 91. 最短Hamilton路径
【点云处理之论文狂读前沿版8】—— Pointview-GCN: 3D Shape Classification With Multi-View Point Clouds
Save the drama shortage, programmers' favorite high-score American drama TOP10
Character pyramid
剑指 Offer II 091. 粉刷房子
随机推荐
Low code momentum, this information management system development artifact, you deserve it!
状态压缩DP AcWing 91. 最短Hamilton路径
即时通讯IM,是时代进步的逆流?看看JNPF怎么说
剑指 Offer II 029. 排序的循环链表
2022-1-6 Niuke net brush sword finger offer
What are the stages of traditional enterprise digital transformation?
Move anaconda, pycharm and jupyter notebook to mobile hard disk
AcWing 785. 快速排序(模板)
State compression DP acwing 91 Shortest Hamilton path
Summary of methods for counting the number of file lines in shell scripts
教育信息化步入2.0,看看JNPF如何帮助教师减负,提高效率?
LeetCode 324. 摆动排序 II
Save the drama shortage, programmers' favorite high-score American drama TOP10
LeetCode 75. Color classification
数位统计DP AcWing 338. 计数问题
Sword finger offer II 091 Paint the house
Computing level network notes
Severity code description the project file line prohibits the display of status error c2440 "initialization": unable to convert from "const char [31]" to "char *"
剑指 Offer II 091. 粉刷房子
Use of sort command in shell