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

How to use redis in java

藏色散人
藏色散人Original
2019-08-29 13:48:534663browse

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!

Statement:
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