首页 > 数据库 >redisTest

redisTest

时间:2023-12-05 09:03:32浏览次数:35  
标签:value jedis student scofield static redisTest public

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

标签:value,jedis,student,scofield,static,redisTest,public
From: https://www.cnblogs.com/y1126/p/17876440.html

相关文章