当前位置:网站首页>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.confredis Service related commands
# Uninstall service : redis-server --service-uninstall # Start the service : redis-server --service-start # Out of Service : redis-server --service-stop
边栏推荐
- 数字化管理中台+低代码,JNPF开启企业数字化转型的新引擎
- [graduation season | advanced technology Er] another graduation season, I change my career as soon as I graduate, from animal science to programmer. Programmers have something to say in 10 years
- 精彩回顾|I/O Extended 2022 活动干货分享
- 2022-2-14 learning the imitation Niuke project - send email
- LeetCode 871. 最低加油次数
- 状态压缩DP AcWing 91. 最短Hamilton路径
- LeetCode 1089. Duplicate zero
- Complex character + number pyramid
- LeetCode 57. Insert interval
- What are the stages of traditional enterprise digital transformation?
猜你喜欢

Pic16f648a-e/ss PIC16 8-bit microcontroller, 7KB (4kx14)

With low code prospect, jnpf is flexible and easy to use, and uses intelligence to define a new office mode

传统企业数字化转型需要经过哪几个阶段?

LeetCode 1089. Duplicate zero
![[point cloud processing paper crazy reading frontier version 10] - mvtn: multi view transformation network for 3D shape recognition](/img/94/2ab1feb252dc84c2b4fcad50a0803f.png)
[point cloud processing paper crazy reading frontier version 10] - mvtn: multi view transformation network for 3D shape recognition

Find the combination number acwing 885 Find the combination number I

LeetCode 515. Find the maximum value in each tree row

Common penetration test range

樹形DP AcWing 285. 沒有上司的舞會

LeetCode 1089. 复写零
随机推荐
LeetCode 324. 摆动排序 II
Divide candy (circular queue)
Problems in the implementation of lenet
Memory search acwing 901 skiing
Find the combination number acwing 886 Find the combination number II
Format - C language project sub file
[point cloud processing paper crazy reading classic version 12] - foldingnet: point cloud auto encoder via deep grid deformation
AcWing 787. Merge sort (template)
AcWing 786. Number k
状态压缩DP AcWing 91. 最短Hamilton路径
On February 14, 2022, learn the imitation Niuke project - develop the registration function
剑指 Offer II 091. 粉刷房子
Instant messaging IM is the countercurrent of the progress of the times? See what jnpf says
State compression DP acwing 91 Shortest Hamilton path
樹形DP AcWing 285. 沒有上司的舞會
On a un nom en commun, maître XX.
Recommend a low code open source project of yyds
Install third-party libraries such as Jieba under Anaconda pytorch
Arbre DP acwing 285. Un bal sans patron.
【点云处理之论文狂读经典版11】—— Mining Point Cloud Local Structures by Kernel Correlation and Graph Pooling