当前位置:网站首页>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
边栏推荐
- 【点云处理之论文狂读经典版13】—— Adaptive Graph Convolutional Neural Networks
- <, < <,>, > > Introduction in shell
- LeetCode 513. Find the value in the lower left corner of the tree
- LeetCode 871. Minimum refueling times
- The method of replacing the newline character '\n' of a file with a space in the shell
- [untitled] use of cmake
- Binary tree traversal (first order traversal. Output results according to first order, middle order, and last order)
- 低代码前景可期,JNPF灵活易用,用智能定义新型办公模式
- AcWing 786. 第k个数
- LeetCode 715. Range 模块
猜你喜欢

20220630 learning clock in

Character pyramid
[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

LeetCode 508. 出现次数最多的子树元素和

LeetCode 715. Range module

What are the stages of traditional enterprise digital transformation?

Excel is not as good as jnpf form for 3 minutes in an hour. Leaders must praise it when making reports like this!

Recommend a low code open source project of yyds

AcWing 785. Quick sort (template)

【点云处理之论文狂读前沿版11】—— Unsupervised Point Cloud Pre-training via Occlusion Completion
随机推荐
低代码起势,这款信息管理系统开发神器,你值得拥有!
Memory search acwing 901 skiing
精彩回顾|I/O Extended 2022 活动干货分享
What are the stages of traditional enterprise digital transformation?
剑指 Offer II 029. 排序的循环链表
<, < <,>, > > Introduction in shell
Six dimensional space (C language)
Facial expression recognition based on pytorch convolution -- graduation project
Common DOS commands
CSDN markdown editor help document
我们有个共同的名字,XX工
求组合数 AcWing 885. 求组合数 I
dried food! What problems will the intelligent management of retail industry encounter? It is enough to understand this article
Solve POM in idea Comment top line problem in XML file
【点云处理之论文狂读前沿版13】—— GAPNet: Graph Attention based Point Neural Network for Exploiting Local Feature
【点云处理之论文狂读经典版9】—— Pointwise Convolutional Neural Networks
AcWing 785. Quick sort (template)
LeetCode 515. Find the maximum value in each tree row
LeetCode 30. Concatenate substrings of all words
Vs2019 configuration opencv3 detailed graphic tutorial and implementation of test code