java 连接Redis的小例子
本文导语: 需要相应API (jedis-2.1.0.jar) 代码如下:package com.redis; import redis.clients.jedis.Jedis; public class Client { public void getCache(String key){ Jedis jedis = new Jedis("127.0.0.1",6379); for (int i = 0; i < 100000; i++){ jed...
需要相应API (jedis-2.1.0.jar)
package com.redis;
import redis.clients.jedis.Jedis;
public class Client {
public void getCache(String key){
Jedis jedis = new Jedis("127.0.0.1",6379);
for (int i = 0; i < 100000; i++){
jedis.set(String.valueOf(i), "kkkk");
}
String value = jedis.get(key);
System.out.println(value);
}
public static void main(String[] args){
Client client = new Client();
client.getCache("key1");
}
}