12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
ADADADADAD
建站问答 时间:2024-12-01 19:16:47
作者:文/会员上传
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
12-09
java开发redis的示例:利用Jedis开发Redis,新建项目引入jedis-2.1.0.jar和commons-pool-1.5.6.jar(可在百度所搜下载),demo代码:public class JedisDemo {public static void main(
以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。
利用Jedis开发Redis,新建项目引入jedis-2.1.0.jar和commons-pool-1.5.6.jar(可在百度所搜下载),demo代码:
public class JedisDemo {
public static void main(String[] args) {
Jedis jedis = new Jedis("127.0.0.1", 6379);
jedis.connect();
jedis.set("message", "Hello World");
System.out.println(jedis.get("message"));
jedis.quit();
}
}
使用Redis连接池Demo,代码:
public class JedisDemo {
public static void main(String[] args) {
JedisPoolConfig config = new JedisPoolConfig();
config.setMaxActive(20);
config.setMaxIdle(5);
config.setMaxWait(1000l);
config.setTestOnBorrow(false);
JedisPool jedisPool = new JedisPool(config, "127.0.0.1", 6379);
Jedis jedis = jedisPool.getResource();
jedis.set("message", "Hello World");
System.out.println(jedis.get("message"));
jedis.quit();
}
}
11-20
11-19
11-20
11-20
11-20
11-19
11-20
11-20
11-19
11-20
11-19
11-19
11-19
11-19
11-19
11-19