SSMR整合

依赖

 
      redis.clients
      jedis
      2.9.0
    
    
      org.springframework.data
      spring-data-redis
      1.6.2.RELEASE
    

单元测试


public class Test1 {

    @Test
    public void test(){
        Jedis jedis = new Jedis("127.0.0.1",6379);
        jedis.select(3);
        jedis.set("aa","bb");
        jedis.close();
    }

redis连接池参数配置



    
    

        
        
        

        
    
    

        

        

        

    
    @Resource
    private JedisPool jedisPool;


    @Override
    public String findAll() {
        jedisPool.getResource().select(3);
        String json = jedisPool.getResource().get("find");
        if (json == null) {
            List lists = studentMapper.findAll();
            json = JSONObject.toJSONString(lists);
            jedisPool.getResource().set("find",json);
        }
        return json;
    }



    @Resource
    StudentService studentService;

    @RequestMapping(value = "/find", produces = "text/json; charset=utf-8")
    @ResponseBody
    public String find(String name,String pwd, HttpSession session){

        return studentService.findAll();
    }

你可能感兴趣的:(java,redis)