Home > Redis > Redis Learning Note – 02 Create Simple Java Client

Redis Learning Note – 02 Create Simple Java Client

I used Jedis as redis client, maven dependency

<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.6.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>

Java class

public class SimpleRedisJava {
public static void main(String[] args){
Jedis jedis = new Jedis("localhost");
System.out.println("Connection to server ok");
System.out.println("Ping to server:" + jedis.ping());

jedis.set("name", "bluething");
System.out.println("Name stored in jedis server: " + jedis.get("name"));
}
}

Run

Screenshot from 2014-11-03 00:38:35

Categories: Redis
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: