当前位置:网站首页>Redis learning journey -- getting to know redis for the first time
Redis learning journey -- getting to know redis for the first time
2022-06-13 07:28:00 【Zhao JC】
Redis Learning journey -- initial redis
** Ben Xiaobai is based on B Station crazy God video learning , If you have any questions, you can leave a comment , Or go B Stand and watch the video to understand !!!** Finally, I would like to thank crazy God Da !
summary
Redis What is it? ?
Redis(Remote Dictionary Server) Remote Dictionary Service ! Is an open source use ANSIC Language To write 、 Support network 、 Log type that can be memory based or persistent 、key-value database , And provide multilingual API. It's free and open source ! It's the hottest thing right now NoSQL One of the technologies ! Also known as structured database !Redis Periodically, updated data is written to disk or changes are written to an appended log file , And on this basis to achieve master-slave( Master-slave ) Sync .
Redis What can I do? ?
- Memory storage 、 Persistence ( In memory, power is lost 、 So persistence is important ( people rdb、aof))
- Efficient 、 Can be used to tell the cache
- Publish subscribe system ( Message queue )
- Map information analysis
- timer 、 Counter ( Browse volume )
- …
Redis Characteristics
- A variety of data types
- Persistence
- colony
- Business
- …
expand
- Redis Official website :https://redis.io/
- Redis Chinese official website :http://www.redis.cn/
Be careful :Wdinow stay Github Upload and download ( It's been a long time !)
Redis The recommendations are all in Linux Built on the server , be based on Linux Study !
download
Windows download
1. Online disk download link https://pan.baidu.com/s/1VHiNbmrupYU2yN9D_nybYQ
2. Unzip it to your computer environment !Redis A very small , Only 5M
3. Turn on Redis, Double click to run the service 
4, Open the client for link test 
Linux install
Download installation package ! Network disk link https://pan.baidu.com/s/1B7VQauxUXbuspqXpQTMcXQ
decompression Redis Installation package ! programmatic /opt Under the table of contents

- Enter the extracted file , You can see us Redis Configuration file for

- Basic environment installation
yum install gcc-c++
make
make install
- Default installation path /usr/local/bin

- Copy the default profile

- Redis It is not started in the background by default , The configuration file needs to be modified

- start-up Redis service

- Use redis-cli Test connection

- see Redis Is the process on ps -ef|grep redis

- close Redis service

- Check to see if the process exists

redis-benchmark( Performance tested )
test :100 Two concurrent connections ,100000 A request
redis-benchmark -h localhost -p 6379 -c 100 -n 100000

View analysis 

Redis Memory retirement strategy
Redis Is to constantly delete some expired data , But there must be more and more data without expiration time , that Redis How to deal with when the memory is not enough ? The answer is the elimination strategy ( When Redis After the memory exceeds the maximum allowed memory ,Redis Will trigger the memory obsolescence policy , Delete some unusual data , In order to make sure Redis The normal operation of the server )
- 1、noeviction: When adding data , If redis Judge that this operation will cause the occupied memory size to exceed the memory limit , Just go back to error, Then do nothing
- 2、allkeys-lru: When adding data , If redis Judge that this operation will cause the occupied memory size to exceed the memory limit , Will scan all key, Eliminate some that have not been used recently key
- 3、volatile-lru: When adding data , If redis Judge that this operation will cause the occupied memory size to exceed the memory limit , Scan the expiration time in the settings key, Eliminate some that have not been used recently key
- 4、allkeys-random: When adding data , If redis Judge that this operation will cause the occupied memory size to exceed the memory limit , Will scan all key, Randomly eliminate some key
- 5、volatile-random: When adding data , If redis Judge that this operation will cause the occupied memory size to exceed the memory limit , Scan the expiration time in the settings key, Randomly eliminate some key
- 6、volatile-ttl: When adding data , If redis Judge that this operation will cause the occupied memory size to exceed the memory limit , Scan the expiration time in the settings key, Eliminate some that are about to expire key
- 7、volatile-lfu: When adding data , If redis Judge that this operation will cause the occupied memory size to exceed the memory limit , Will eliminate some set expiration time , And the least used recently key
- 8、allkeys-lfu: When adding data , If redis Judge that this operation will cause the occupied memory size to exceed the memory limit , Will scan all key, Eliminate some of the least recently used key
Redis Basic knowledge of
Relevant concepts
Redis Yes 16 A database , By default, the number... Is used 0 individual , It can be used select Command to switch 
Different databases store different values , Do not interfere with each other 
- keys * See all the keywords
- flushdb Clear current database
- flushall Clear all database contents

Redis It's single threaded !
We need to understand Redis It's very fast , Official expression ,Redis It's based on memory operations ,CPU No Redis Performance bottlenecks ,Redis The bottleneck is related to the memory and network bandwidth of the machine , Since you can use single threads , It is realized by single thread !
Redis Yes, it is c Written language , The official data is 1000000+ Of QPS, It's no better than using the same key-value Of Memecache Bad !
Redis Why is single thread so fast ?
myth 1: Does a high-performance server have to be multi-threaded ?
myth 2: Multithreading (CPU Context switching will be performed ) It must be more efficient than a single thread ?
The core : efficiency :CPU > Memory > Hard disk Redis Is to put all the data in memory , It is said that using a single thread to operate is the most efficient ( Multithreading CPU The context switches , It takes time ) For memory systems , If there is no context switching, the efficiency is the highest !
边栏推荐
- Personal JS learning notes
- Compare advantages and disadvantages of DFS and BFS and name vocabulary
- 量化框架backtrader之一文读懂Analyzer分析器
- 【ViveFocus使用WaveVR插件获取手柄操作事件】
- 简单了解C语言基本语
- 【splishsplash】重复输出splashsurf的脚本
- RT thread simulator lvgl control: slider control
- C Advanced Programming - features
- redis-2. Redis string type & bitmap
- Make cer/pfx public and private key certificates and export CFCA application certificates
猜你喜欢

Compare advantages and disadvantages of DFS and BFS and name vocabulary

Tidb data migration (DM) Introduction

全志V3S环境编译开发流程

10 Honest Facts I Want To Share With All Junior Developers

The biggest highlight of wwdc2022: metalfx

redis-6. Redis master-slave replication, cap, Paxos, cluster sharding cluster 01

redis-3. Redis list, set, hash, sorted_ set、skiplist

RT thread simulator lvgl control: switch switch button control

It's called the next generation monitoring system. Let's see how awesome it is

socket编程2:IO复用(select && poll && epoll)
随机推荐
One article of quantitative framework backtrader read analyzer
Calculate running total / running balance
redis-2. Redis string type & bitmap
Time field comparison time size in MySQL
Vsys of Isis (virtual system)
The 'yarn' item cannot be recognized as the name of a cmdlet, function, script file, or runnable program
How idea breaks point debugging
Sharp weapon tcpdump
c#高级编程-特性篇
Local file upload FTP or remote directory
Nodejs file module FS
检测循环数“142857“
关于#数据库#的问题:PGADMIN4 编辑sql窗口问题
No configure file found when compiling PHP from source code
Number of detection cycles "142857“
Three handshakes and four waves of TCP protocol and why------ One two pandas
How is it that the income of financial products is zero for several consecutive days?
How to write an amazing design document?
RT-Thread 模拟器 simulator LVGL控件:slider 控件
About database: pgadmin4 editing SQL window