发表于: 2017-06-29 10:58:37

1 989


今日完成

http://www.cnblogs.com/chy2055/p/4441478.html

 java_memcached-release_2.6.6.jar这个依赖中央库是没有的,折腾一上午终于报错解决

之前的bug是因为出现了两个properties配置,memcached.properties和jdbc.properties。

bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
<value>classpath:memcached.properties</value>
</list>
</property>
</bean>

这样配置就都能读取了

public List<Student> getAllStudent() {
List<Student> listStudent = null;
if (MemcachedUtils.get("listStudent") != null) {
listStudent = (List<Student>) MemcachedUtils.get("listStudent");
System.out.print("所请求数据是从缓存中取出");
return listStudent;
}

listStudent = studentDao.select();
MemcachedUtils.add("listStudent", listStudent);
System.out.print("所请求数据是从数据库中查询取出,已添加至缓存中");
return listStudent;
}

serviceImpl实现缓存读取方法

试了几次都没有出现缓存读取,从实例入手看看。

http://www.cnblogs.com/cl1234/p/5391401.html

参照这个把bug揪出来了

[ERROR] attempting to get SockIO from uninitialized pool!

原因是:spring-memcached.xml中的 memcachedPool 的名字要和MemcachedUtils.java中new MemCachedClient("memcachedPool"); 的名字对应起来。

神tm查了那么久!!!

再次访问页面数据能从缓存中取出来了。

收获

Spring MVC整合memcached

困难

已解决

明日计划

Redis整合完了后Jmeter压测对比吧


返回列表 返回列表
评论

    分享到