Skip to content

Commit 8d2be95

Browse files
committed
redis demos
1 parent 35c531a commit 8d2be95

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

src/org/jee/redis/RedisPing.java

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.jee.redis;
2+
3+
import redis.clients.jedis.Jedis;
4+
5+
/**
6+
* Created by bysocket on 16/3/25.
7+
*/
8+
public class RedisPing {
9+
public static Jedis jedis;
10+
public static void main(String[] args) {
11+
pingRedis();
12+
}
13+
14+
public static void pingRedis(){
15+
jedis = new Jedis("localhost");
16+
System.out.println("Server is running: " + jedis.ping());
17+
}
18+
}

src/org/jee/redis/RedisString.java

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.jee.redis;
2+
3+
/**
4+
* Created by bysocket on 16/3/25.
5+
*/
6+
public class RedisString {
7+
public static void main(String[] args) {
8+
setGetString();
9+
}
10+
11+
public static void setGetString() {
12+
RedisPing.pingRedis();
13+
14+
// set redis string
15+
RedisPing.jedis.set("name","bysocket");
16+
17+
// get redis string
18+
System.out.println(RedisPing.jedis.get("name"));
19+
20+
}
21+
}

0 commit comments

Comments
 (0)