当前位置:网站首页>One of the project optimization: the installation and use of redis cache database in the project, and strengthen the project reading operation
One of the project optimization: the installation and use of redis cache database in the project, and strengthen the project reading operation
2022-07-21 20:11:00 【Cold moon and snow】
One 、redis brief introduction
redis It's a key-value The storage system . and Memcached similar , It supports storage value There are more types , Include string( character string )、list( Linked list )、set( aggregate )、zset(sorted set -- Ordered set ) and hash( Hash type ). These data types support push/pop、add/remove And take intersection, union and difference sets and more abundant operations , And these operations are atomic . On this basis ,redis Support various sorts of sorting . And memcached equally , To ensure efficiency , The data is cached in memory . The difference is 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 Is a high-performance key-value database . redis Appearance , A lot of compensation memcached This kind of key/value Insufficient storage , In the department The situation can be a good complement to the relational database . It provides Java,C/C++,C#,PHP,JavaScript,Perl,Object-C,Python,Ruby,Erlang Such as the client , Easy to use
Redis Support master-slave synchronization . Data can be synchronized from the master server to any number of slaves , A slave server can be the master server associated with other slaves . This makes Redis Single-layer tree replication can be performed . The disk can write to the data intentionally or unintentionally . Due to the full implementation of the release / Subscribe mechanism , Enables trees to be synchronized anywhere from the database , Subscribe to a channel and receive a complete record of message publication from the master server . Synchronization helps with scalability and data redundancy for read operations .
1.1 install redis
Jump to download address
After entering , You will see the following pictures , It is not recommended to download the pre release version , There will be many problems , Including the ones you installed before maven The latest version also has many problems , therefore , Installing the version is important , With 3.0.504 For example
Unpack after installation , After finishing the above operation , use cmd Open the extracted location , Enter the command :
redis-server.exe redis.windows.conf, You will see the following
After this operation , Don't close this window , Continue to open new cmd Window page . Switch to redis Under the installation directory . Enter the command
redis-cli.exe -h 127.0.0.1 -p 6379
The stored key value pairs are shown in the figure below :
And then modify redis Configuration file for , Input :config get * View all configurations
Two 、 stay Java Project use redis
After the above operations are completed , stay java Yes, you can redis It's like a fish in water , With maven Project as an example , First, go to the central warehouse to download jedis Related dependence of :
Click to enter , Here we need to pay attention to , To be on the safe side, I suggest you go to the one with a large number of downloads , Prevent other problems :
Then use in the project :
You can see that the value is saved successfully ,dedis.ping Used to check the status , Of course, there are other 3 Storage of data types in , If there is time , Update the blog later .
thus , Configuration and use complete , If you don't understand, you can comment on it below and we can discuss it together .
边栏推荐
- MySQL DCL (data control language)
- RSA公私钥加密工具类
- Share pictures or link to Tiktok
- In depth interpretation of the investment logic of the consortium's participation in the privatization of Twitter
- 866. Trial division to determine prime numbers
- 逐步理解深度信念网络
- RSA public private key encryption tool class
- 869. Trial division for divisor
- 【无标题】
- 微信公眾號開發接入,利用微信公眾平臺申請測試號進行本地開發
猜你喜欢
高德地图API获取当前位置对应的周边信息
One of the problems to solve the sorting order error of Oracle database query single table
Paper reading (61):multi instance attention network for few shot learning
Iwemeta: Shi Yuzhu's golden sauce wine: OEM factories have been shut down. Who is producing it?
Detailed explanation and use of swagger
Json工具 将对象转换为json格式字符串
数据库设计 数据库系统概论(第五版)
Wechat public number Development Access, Application for Test number for Local Development Using Wechat public Platform
(4) Transactions
Error in pulling project POM file, Jai_ core-1.1.3. Jar, solve the problem of introducing jar
随机推荐
3D数学之三角公式
How to choose sentinel vs. hystrix current limiting?
Linux系统Redis安装
Chart is code: build a new generation of graphics library in a coded way -- feekin
2022.7.19DAY610
1451 - Cannot delete or update a parent row 具有多个外键约束 删除子表数据行的问题
Incomplete access to wechat database handle
10 lines of code to realize wechat applet payment function, and use applet cloud development to realize applet payment function (including source code
14. Can you tell the difference between process and thread
MySQL之DCL(数据控制语言)
MySQL UPDATE statement or delete statement where condition will lock the table if there is no index
Share the experience of big factories, come quickly
869. Trial division for divisor
MATLAB 自然样条函数(Spline,非MATLAB内置函数)
Trigonometric formula of 3D mathematics
Share pictures or link to Tiktok
fastJson数据类型中,解析JSONObject出现$ref: “$.list[0]“问题
2022DASCTF MAY web
MySQL之DML(数据操纵语言)
1451 - cannot delete or update a parent row has multiple foreign key constraints to delete the data rows of the sub table