当前位置:网站首页>Windows redis installation and simple use

Windows redis installation and simple use

2022-06-25 23:29:00 Justion_

Demand background

Currently using Alibaba Egg.js Develop background applications , Considering that some highly concurrent interfaces often call database queries , So add Redis As a server-side cache .

Solution

1、 install Redis, Because the system is Windows7, Therefore, you need to download the corresponding Windows Version of , Download address :https://github.com/MicrosoftArchive/redis/releases

2、 Simple configuration Redis start-up , by Redis Add password to your connection , To ensure safety

Core code

install Redis

Visit the above 【 Download address 】, Select the version you want , an Assets Catalog , You can choose .msi File or .zip File download . If you download .msi file , You can perform the installation directly ( Check the corresponding check box ), If you download .zip file , You can refer to the link 【Window To configure Redis Environment and simple use 】 https://www.cnblogs.com/wxjnew/p/9160855.html To install and configure .

Check Windows service

With Windows7 For example , Can enter the   Control panel \ All control panel items \ Management tools find 【 service 】, After the light , Find... In the service list Redis.

Redis Startup and shutdown

Once installed , We can start and shut down through services Redis 了 , We can view the task manager of the system , Check if... Is started redis-server, Here is redis-server Startup and shutdown commands :

$ redis-server.exe  --service-start #  start-up 
$ redis-server.exe  --service-stop #  close 

Use cli

confirm redis-server After starting , We can execute redis In the catalog redis-cli.exe file , So you can connect to Redis 了 . Of course , We can also use the command line CMD To link Redis.

It can be done directly Redis Accessed :

$ redis-cli.exe -h 127.0.0.1 -p 6379
127.0.0.1:6379> set firstKey "moyufed"
OK
127.0.0.1:6379> get firstKey
"moyufed"
127.0.0.1:6379>

Add password

stay Redis In the installation directory of , Yes redis.windows.conf ,redis.windows-service.conf Two documents , We use Notepad to open ( recommend Notepad++), Find the line that needs to set the password , Sure Ctrl + F lookup “requirepass” The line of ( Probably 386 Row position ), Set separately Redis password ( Get rid of the front “#”), Example :

requirepass moyufed

Use Redis

Restart after modification redis-server , Now connect Redis after Redis Access requires login , Example :

[email protected] C:\Users\Administrator
$ redis-server.exe  --service-stop
[42636] 25 Feb 18:42:53.622 # Redis service successfully stopped.

[email protected] C:\Users\Administrator
$ redis-server.exe  --service-start
[38828] 25 Feb 18:42:58.576 # Redis service successfully started.

[email protected] C:\Users\Administrator
$ redis-cli.exe -h 127.0.0.1 -p 6379
127.0.0.1:6379> set firstKey "moyufed"
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth moyufed
OK
127.0.0.1:6379> set firstKey "moyufed"
OK
127.0.0.1:6379> get firstKey
"moyufed"
127.0.0.1:6379>

Reference documents

Window To configure Redis Environment and simple use :https://www.cnblogs.com/wxjnew/p/9160855.html

Windows Next Redis Installation, configuration and use precautions :https://www.cnblogs.com/LMJBlogs/p/11550170.html

原网站

版权声明
本文为[Justion_]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206252008391383.html