import java.util.Map;
import redis.clients.jedis.Jedis;

public class redisTest {

/**
* @param args
*/
public static Jedis jedis;

public static void main(String[] args) {
// TODO Auto-generated method stub
jedis = new Jedis("localhost");
//插入数据
// test1();
//查询数据
test2();
}

public static void test1() {
// TODO Auto-generated method stub
jedis.hset("student.scofield", "English","45");
jedis.hset("student.scofield", "Math","89");
jedis.hset("student.scofield", "Computer","100");
Map<String,String> value = jedis.hgetAll("student.scofield");
for(Map.Entry<String, String> entry:value.entrySet())
{
System.out.println(entry.getKey()+":"+entry.getValue());
}
}

public static void test2() {
// TODO Auto-generated method stub
String value=jedis.hget("student.scofield", "English");
System.out.println("scofield's English score is: "+value);
}
}
posted on 2023-12-05 08:21  夜的第七章i  阅读(5)  评论(0编辑  收藏  举报