/** * redis简单测试 * redis-server.exe redis.conf * @author xzm * */ public class RedisTest { public static void main(String[] args) { Jedis redis = new Jedis("localhost", 6379); redis.hset("mytest", "1", "a"); redis.hset("mytest", "2", "aa"); redis.hset("mytest", "3", "aaa"); redis.hset("mytest", "4", "aaaa"); redis.hset("mytest", "5", "aaaaa"); List<String> list = null; list = redis.hmget("mytest", "1","2","3"); for (String str : list) { System.out.println(str); } Map<String,String> map = new HashMap<String, String>(); map.put("username", "1234"); map.put("password", "5678"); redis.hmset("hash", map); System.out.println(redis.hget("hash", "username")); map = redis.hgetAll("hash"); for (Map.Entry<String, String> obj : map.entrySet()) { System.out.println(obj.getKey()+" "+obj.getValue()); } } }