Java Operations Redis is a must-learn content, then I directly on a super simple case for you to refer to the next!
First, create the Redistest class, the code is as follows!
Import Redis.clients.jedis.jedis;public class Redistest {public static void main (string[] args) {//TODO auto- Generated method stub//Connect Redis service Jedis Jedis = new Jedis ("127.0.0.1", 6379); Password verification-If you do not set up a redis password, you can use the relevant command//jedis.auth ("ABCDEFG") without verifying it. Simple Key-value storage Jedis.set ("Redis2", "Myredis2"); System.out.println (Jedis.get ("Redis2")); System.out.println (); }}
Printing results such as:
Check in the terminal to verify that it is correct:
See it! In the terminal can also be output, that is to say, our Java has successfully operation of Redis! Small partners who are not very knowledgeable about Redis can go straight to redis session.
A simple example of the Java operation Redis