1、服务器
下载redis Windows版,命令行启动redis-server.exe即可。
2、客户端使用 jedis
添加DLL:
commons-pool2-2.0.jar
jedis-2.4.2.jar
3、源码示例:
package nankang.test; import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig; public class Main { /**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try { JedisPoolConfig config = new JedisPoolConfig();
JedisPool pool = new JedisPool(config, "127.0.0.1"); Jedis jedis = pool.getResource(); jedis.set("name", "sun shoubin");
System.out.println(jedis.get("name")); jedis.append("name", "sun shoubin2");
System.out.println(jedis.get("name")); jedis.set("name", "sun shoubin3");
System.out.println(jedis.get("name")); jedis.del("name");
System.out.println(jedis.get("name")); System.out.println("导出成功");
} catch (Exception e) {
System.out.println(String.format("导出失败,%s", e.getMessage()));
} System.exit();
} }
4、相关包下载:百度网盘