12.28每日总结

发布时间 2023-12-28 21:39:37作者: 风·华正茂

redis测试:

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);
}
}