Skip to content

Instantly share code, notes, and snippets.

@jebai0521
Created January 13, 2016 10:46
Show Gist options
  • Save jebai0521/be112858ab6fc9b4e70b to your computer and use it in GitHub Desktop.
Save jebai0521/be112858ab6fc9b4e70b to your computer and use it in GitHub Desktop.
java 使用 redis
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