当前位置:网站首页>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
边栏推荐
- Linxu learning (4) -- Yum and apt commands
- 【点云处理之论文狂读经典版13】—— Adaptive Graph Convolutional Neural Networks
- Binary tree sorting (C language, char type)
- AcWing 786. 第k个数
- 浅谈企业信息化建设
- [advanced feature learning on point clouds using multi resolution features and learning]
- LeetCode 535. TinyURL 的加密与解密
- Using DLV to analyze the high CPU consumption of golang process
- The difference between if -n and -z in shell
- PIC16F648A-E/SS PIC16 8位 微控制器,7KB(4Kx14)
猜你喜欢

dried food! What problems will the intelligent management of retail industry encounter? It is enough to understand this article

How to check whether the disk is in guid format (GPT) or MBR format? Judge whether UEFI mode starts or legacy mode starts?

LeetCode 515. 在每个树行中找最大值
[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

Binary tree sorting (C language, int type)

低代码前景可期,JNPF灵活易用,用智能定义新型办公模式

树形DP AcWing 285. 没有上司的舞会

Gaussian elimination acwing 883 Gauss elimination for solving linear equations

Common penetration test range

AcWing 786. Number k
随机推荐
LeetCode 438. 找到字符串中所有字母异位词
Tree DP acwing 285 A dance without a boss
树形DP AcWing 285. 没有上司的舞会
Divide candy (circular queue)
数位统计DP AcWing 338. 计数问题
What is an excellent fast development framework like?
LeetCode 871. 最低加油次数
2022-2-14 learning xiangniuke project - generate verification code
State compression DP acwing 291 Mondrian's dream
Memory search acwing 901 skiing
[point cloud processing paper crazy reading frontier version 10] - mvtn: multi view transformation network for 3D shape recognition
干货!零售业智能化管理会遇到哪些问题?看懂这篇文章就够了
【点云处理之论文狂读经典版13】—— Adaptive Graph Convolutional Neural Networks
[advanced feature learning on point clouds using multi resolution features and learning]
【点云处理之论文狂读前沿版10】—— MVTN: Multi-View Transformation Network for 3D Shape Recognition
Binary tree traversal (first order traversal. Output results according to first order, middle order, and last order)
精彩回顾|I/O Extended 2022 活动干货分享
Data mining 2021-4-27 class notes
【点云处理之论文狂读经典版10】—— PointCNN: Convolution On X-Transformed Points
Method of intercepting string in shell