当前位置:网站首页>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
边栏推荐
- String splicing method in shell
- On a un nom en commun, maître XX.
- 【点云处理之论文狂读前沿版9】—Advanced Feature Learning on Point Clouds using Multi-resolution Features and Learni
- Methods of using arrays as function parameters in shell
- LeetCode 241. 为运算表达式设计优先级
- Internet Protocol learning record
- LeetCode 241. Design priorities for operational expressions
- 【点云处理之论文狂读经典版11】—— Mining Point Cloud Local Structures by Kernel Correlation and Graph Pooling
- LeetCode 535. TinyURL 的加密与解密
- Digital statistics DP acwing 338 Counting problem
猜你喜欢

PIC16F648A-E/SS PIC16 8位 微控制器,7KB(4Kx14)

Find the combination number acwing 886 Find the combination number II

Character pyramid

精彩回顾|I/O Extended 2022 活动干货分享

【点云处理之论文狂读经典版11】—— Mining Point Cloud Local Structures by Kernel Correlation and Graph Pooling

【点云处理之论文狂读前沿版13】—— GAPNet: Graph Attention based Point Neural Network for Exploiting Local Feature

剑指 Offer II 091. 粉刷房子

CSDN markdown editor help document

AcWing 786. 第k个数

In the digital transformation, what problems will occur in enterprise equipment management? Jnpf may be the "optimal solution"
随机推荐
LeetCode 871. 最低加油次数
LeetCode 438. Find all letter ectopic words in the string
LeetCode 1089. 复写零
LeetCode 324. 摆动排序 II
干货!零售业智能化管理会遇到哪些问题?看懂这篇文章就够了
Find the combination number acwing 885 Find the combination number I
On a un nom en commun, maître XX.
[point cloud processing paper crazy reading classic version 14] - dynamic graph CNN for learning on point clouds
状态压缩DP AcWing 291. 蒙德里安的梦想
[point cloud processing paper crazy reading classic version 9] - pointwise revolutionary neural networks
Sword finger offer II 091 Paint the house
State compression DP acwing 91 Shortest Hamilton path
LeetCode 438. 找到字符串中所有字母异位词
Methods of checking ports according to processes and checking processes according to ports
LeetCode 513. 找树左下角的值
LeetCode 532. K-diff number pairs in array
LeetCode 30. 串联所有单词的子串
Vscode connect to remote server
2022-2-14 learning xiangniuke project - Session Management
低代码前景可期,JNPF灵活易用,用智能定义新型办公模式