Created
January 13, 2016 10:46
-
-
Save jebai0521/be112858ab6fc9b4e70b to your computer and use it in GitHub Desktop.
java 使用 redis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.sencloud.redis.test; | |
import redis.clients.jedis.Jedis; | |
public class Test | |
{ | |
public static void main(String[] args) | |
{ | |
System.out.println("hellow"); | |
Jedis jedis = new Jedis("node1", 6379); | |
jedis.setex("test", 10, "测试node1"); // 设置10秒超时 | |
String value = jedis.get("test"); | |
System.out.println(value); | |
Jedis jedis2 = new Jedis("node2", 6379); | |
jedis2.setex("test", 10, "测试node2"); // 设置10秒超时 | |
String value2 = jedis2.get("test"); | |
System.out.println(value2); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment