Java using Redis
installation
Before we start using Redis in Java, we need to make sure that the Redis service and the Java Redis Drive are installed and that Java is available on your machine. Java installation configuration can refer to the Java Development environment configuration next let's install the Java Redis driver:
Use Java operation Redis need jedis-2.1.0.jar, download address: Http://files.cnblogs.com/liuling/jedis-2.1.0.jar.zip
If you need to use Redis connection pool, also need Commons-pool-1.5.4.jar, download address: Http://files.cnblogs.com/liuling/commons-pool-1.5.4.jar.zip Connecting to the Redis service
Import Redis.clients.jedis.Jedis;
public class Redisjava {public
static void Main (string[] args) {
//Connect local Redis service
Jedis Jedis = new Jedis ("Lo Calhost ");
System.out.println ("Connection to Server sucessfully");
To see if the service is running
System.out.println ("Server is running:" +jedis.ping ());
}
Compile the Java program above to ensure that the path to the driver package is correct.
$javac Redisjava.java
$java redisjava
Connection to server sucessfully
server is Running:pong
Redis Java String Example