Home > Database > Redis > How to use redis

How to use redis

藏色散人
Release: 2019-08-29 13:31:47
Original
11398 people have browsed it

How to use redis

How to use redis?

After installing redis, enter "redis-cli" on the command line and enter "auth passowod" to confirm whether redis is installed.

How to use redis

Create a new web project. The project structure diagram is as follows.

How to use redis

Set key-value pairs in the SpirngRedis file and obtain the corresponding values ​​of the keys. See the code below.

How to use redis

Save the User object in the UserServiceTest file and query it after saving. The code is as shown in the figure below.

How to use redis

Set the redis cache and cache name in the spring-redis.xml file. The code is as shown below.

How to use redis

Introduce the spring-redis.xml and spring-datasource-bonecp.xml files into the beans.xml file respectively. The code is shown below.

How to use redis

Use spring annotations in the userservice file to cache the data saved in userservicetest. The name is the same as that saved in the spring-redis.xml file, as pointed by the red arrow in the figure below.

How to use redis

Finally open it, the userservicetest file will run and the data will be retrieved directly from the cache, as shown in the figure below.

How to use redis

The above is the detailed content of How to use redis. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template