xml配置文件

<bean id="memcachedPool" class="com.danga.MemCached.SockIOPool"
factory-method="getInstance" init-method="initialize" destroy-method="shutDown">
<constructor-arg>
<value>neeaMemcachedPool</value>
</constructor-arg>
<property name="servers">
<list>
<value>192.168.174.104:</value>
</list>
</property>
<property name="initConn">
<value></value>
</property>
<property name="minConn">
<value></value>
</property>
<property name="maxConn">
<value></value>
</property>
<property name="maintSleep">
<value></value>
</property>
<property name="nagle">
<value>false</value>
</property>
<property name="maxIdle">
<value></value>
</property>
<property name="socketTO">
<value></value>
</property>
</bean>
<!--memcached client -->
<bean id="memCachedClient" class="com.danga.MemCached.MemCachedClient">
<constructor-arg>
<value>neeaMemcachedPool</value>
</constructor-arg>
</bean>

JAVA调用

@Primary
@Repository
public class GoodsMemDao implements GoodsDAO{ private final String MEM_PRE="goods_"; @Autowired
private GoodsMapperDAO goodsDao; @Autowired
private MemCachedClient memClient; public void create(GoodsModel m) {
goodsDao.create(m);
} public void update(GoodsModel m) {
goodsDao.update(m); Object obj=memClient.get(MEM_PRE+m.getUuid());
if(obj!=null){
memClient.set(MEM_PRE+m.getUuid(), m);
} } public void delete(Integer uuid) {
goodsDao.delete(uuid);
Object obj=memClient.get(MEM_PRE+uuid);
if(obj!=null){
memClient.delete(MEM_PRE+uuid);
}
} public GoodsModel getByUuid(Integer uuid) { Object obj=memClient.get(MEM_PRE+uuid);
if(obj !=null){
return (GoodsModel) memClient.get(MEM_PRE+uuid);
} GoodsModel goods=goodsDao.getByUuid(uuid);
memClient.set(MEM_PRE+uuid, goods); return goods;
} }

最新文章

  1. Socket与Http方式解析发送xml消息封装中间件jar包
  2. [20150925]Linux之文件系统与SHELL
  3. ueditor集成自己的ImageServer时出现错误的原因分析
  4. java yum安装的环境变量设置
  5. JavaScript Modules
  6. [2-sat]HDOJ1824 Let&#39;s go home
  7. Sencha Touch id 和 itemId
  8. (转载)关于ArrayList的5道面试题
  9. Median of Two Sorted Arrays 解答
  10. vi编辑器使用介绍
  11. about greenplum collection tool
  12. U盘安装VMware ESXi 6.0
  13. [Leetcode] DP -- Target Sum
  14. WEB 小案例 -- 网上书城(一)
  15. cut命令及参数企业案列讲解及awk对比
  16. 在Asp.Net Core中集成Kafka
  17. 评价指标整理:Precision, Recall, F-score, TPR, FPR, TNR, FNR, AUC, Accuracy
  18. Verilog设计异步FIFO
  19. ROS rosrun 调用 sudo 命令
  20. Python 内置函数sorted()在高级用法

热门文章

  1. 有效管理进程的几个linux命令
  2. websocket原理、为何能实现持久连接?
  3. vue 中引入第三方js库
  4. Csdn账号如何注销?
  5. ListView在编辑状态下不能获取修改后的值,无法更新数据
  6. Linux -- 进程或线程独占CPU
  7. Linux 远程登陆图形界面
  8. yum命令配置及使用说明和常见问题处理
  9. mudos源码分析
  10. 陷门函数Trapdoor Function