@Autowired
@Qualifier("redisTemplate")
private RedisTemplate<String, String> stringredisTemplate; @Autowired
@Qualifier("jdkredisTemplate")
private RedisTemplate<Object, Object> jdkredisTemplate; @Autowired
@Qualifier("jacksonredisTemplate")
private RedisTemplate<Object, Object> jacksonredisTemplate; public void flushdb(){
stringredisTemplate.execute(new RedisCallback<Object>() {
public String doInRedis(RedisConnection connection) throws DataAccessException {
connection.flushDb();
return "ok";
}
});
}
@Test
public void test(){
flushdb(); StopWatch sw = new StopWatch("StringRedisSerializer");
sw.start("stringredisTemplate");
for(int i = 0;i<100;i++){
stringredisTemplate.opsForValue().set("hello", "nihao");
stringredisTemplate.opsForValue().get("hello");
}
sw.stop(); sw.start("jdkredisTemplate");
for(int i = 0;i<100;i++){
User u = new User();
jdkredisTemplate.opsForValue().set("hello", u);
jdkredisTemplate.opsForValue().get(u);
}
sw.stop(); sw.start("jacksonredisTemplate");
for(int i = 0;i<100;i++){
User u = new User();
jacksonredisTemplate.opsForValue().set("hello", u);
jacksonredisTemplate.opsForValue().get(u);
}
sw.stop(); System.out.println(sw.prettyPrint()); }

Spring RedisTemplate操作-序列化性能测试(12)的更多相关文章

  1. Spring RedisTemplate操作-xml配置(1)

    网上没能找到全的spring redistemplate操作例子,故特意化了点时间做了接口调用练习,基本包含了所有redistemplate方法. 该操作例子是个系列,该片为spring xml配置, ...

  2. Spring RedisTemplate操作-发布订阅操作(8)

    @Component("sub") public class Sub implements MessageListener{ @Autowired private StringRe ...

  3. Spring RedisTemplate操作-事务操作(9)

    @Autowired @Qualifier("redisTemplate") private RedisTemplate<String, String> stringr ...

  4. Spring RedisTemplate操作-通道操作(10)

    @Autowired @Resource(name = "redisTemplate") private RedisTemplate<String, String> r ...

  5. Spring RedisTemplate操作-HyperLogLog操作(7)

    @Autowired @Resource(name="redisTemplate") private RedisTemplate<String, String> rt; ...

  6. Spring RedisTemplate操作-Set操作(5)

    @Autowired @Resource(name="redisTemplate") private RedisTemplate<String, String> rt; ...

  7. Spring RedisTemplate操作-ZSet操作(6)

    @Autowired @Resource(name="redisTemplate") private RedisTemplate<String, String> rt; ...

  8. Spring RedisTemplate操作-List操作(4)

    @Autowired @Resource(name="redisTemplate") private RedisTemplate<String, String> rt; ...

  9. Spring RedisTemplate操作-哈希操作(3)

    @Autowired @Resource(name="redisTemplate") private RedisTemplate<String, String> rt; ...

随机推荐

  1. ESXi 更新补丁 暂时未测试 等有时间尝试一下.

    下载地址: https://my.vmware.com/group/vmware/patch 使用操作图: 选择相应的zip包下载即可 更新方式: 命令方式升级ESXi主机补丁包 1.进入VMware ...

  2. Angular 行内式依赖注入

    var app = angular.module('myApp', ['ng']); //创建一个自定义服务app.factory('$Debug', function () { return { d ...

  3. 暂时刷完leetcode的一点小体会

    两年前,在实习生笔试的时候,笔试百度,对试卷上很多问题感到不知所云,毫无悬念的挂了 读研两年,今年代笔百度,发现算法题都见过,或者有思路,但一时之间居然都想不到很好的解法,而且很少手写思路,手写代码, ...

  4. python---random模块详解

    在python中用于生成随机数的模块是random,在使用前需要import, 下面看下它的用法. random.random random.random()用于生成一个0到1的随机符点数: 0 &l ...

  5. SQL注入方法之:获取列名

    select col_name(object_id('table'),1) from sysobjects where name='table'

  6. MT【18】幂平均不等式的证明

    评:证明时对求导要求较高,利用这个观点,对平时熟悉的调和平均,几何平均,算术平均,平方平均有了更深 刻的认识.

  7. Spring事务说明与自实现

    要使用Springboot的事务其实非常简单,在启动类上添加@EnableTransactionManagement,在Service的类或者方法上使用@Transactional就可以了. 事务本身 ...

  8. history新增方法

    history对象包含用户访问过的URL,属于window对象的一部分,传统的使用中,它拥有length属性(浏览器历史列表URL数目) 及back().forward().go()方法. 而新的H5 ...

  9. 洛谷 P1613 跑路 解题报告

    P1613 跑路 题目描述 小\(A\)的工作不仅繁琐,更有苛刻的规定,要求小\(A\)每天早上在\(6:00\)之前到达公司,否则这个月工资清零.可是小\(A\)偏偏又有赖床的坏毛病.于是为了保住自 ...

  10. JDK源码分析(4)HashSet

    JDK版本 HashSet简介 HashSet特点 非线程安全 允许null值 添加值得时候会先获取对象的hashCode方法,如果hashCode 方法返回的值一致,则再调用equals方法判断是否 ...