RedisTemplate的配置

在项目中使用RedisTemplate,spring的配置文件如下







 
 





 




 
 
  
 

 



 





 


 

 
 
 


  
   
   
   
 

 


测试往redis写入1000个对像


ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
    
RedisTemplate rs=ctx.getBean(RedisTemplate.class);

    
    

Long start=System.currentTimeMillis();


for(int i=0;i<1000;i++) {

Role role=new Role(String.valueOf(i)+"test");
rs.opsForValue().set("test"+i, role);



}

      System.out.println("total:"+(System.currentTimeMillis()-start));
}

你可能感兴趣的:(JAVA,Spring)