Home > Database > Redis > How to use redis in java

How to use redis in java

藏色散人
Release: 2019-08-29 13:48:53
Original
4631 people have browsed it

How to use redis in java

#How to use redis in java?

The first step is to install redis on our computer, go to the redis directory, double-click to open "redis-server.exe", as shown in the following figure:

How to use redis in java

After opening the redis service in the second step, load the jedis.jar package into the java project, and connect the local Redis service through "Jedis jedis = new Jedis("localhost");", "jedis.ping() "To test whether the service is running, here is a jedis.jar download address "https://pan.baidu.com/s/1QGcYDEQss3MGHDMT7RviKg", as shown in the figure below:

How to use redis in java

The third step is to set the redis string data and retrieve the stored data. jedis.set("mykey", "Baidu"); set the data and jedis.get("mykey") to retrieve the data, as shown in the following figure:

How to use redis in java

In the fourth step, we can also set the list list data. The code is as shown below:

How to use redis in java

The fifth step Run the project and you can see the data taken out from redis on the console, as shown in the figure below:

How to use redis in java

The above is the detailed content of How to use redis in java. 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