Memcached和Spring集成开发
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;
} }
Memcached和Spring集成开发的更多相关文章
- Spring 集成开发工具(STS)安装及配置
安装 spring 集成开发工具,下载地址:https://spring.io/tools 下载后,解压,双击 STS ,运行. 如果提示: 去oracle的网站上下载了1.8版本的jdk,下载地址如 ...
- memcached与spring集成
一.背景 销售CRM(项目A)将负责管理项目信息系统(项目B)的支付与权限 上级要求为避免频繁调用CRM接口,中间放一级缓存,但要做到缓存中保证最新数据 因项目B已使用memcache作缓存,所以决定 ...
- Memcached与Spring集成的方式(待实践)
主要是基于这几种方式http://www.cnblogs.com/EasonJim/p/7624822.html去实现与Spring集成,而个人建议使用Xmemcached去集成好一些,因为现在官方还 ...
- 从零开始学 Java - Spring 集成 Memcached 缓存配置(二)
Memcached 客户端选择 上一篇文章 从零开始学 Java - Spring 集成 Memcached 缓存配置(一)中我们讲到这篇要谈客户端的选择,在 Java 中一般常用的有三个: Memc ...
- 从零开始学 Java - Spring 集成 Memcached 缓存配置(一)
硬盘和内存的作用是什么 硬盘的作用毫无疑问我们大家都清楚,不就是用来存储数据文件的么?如照片.视频.各种文档或等等,肯定也有你喜欢的某位岛国老师的动作片,这个时候无论我们电脑是否关机重启它们永远在那里 ...
- SSM框架开发web项目系列(五) Spring集成MyBatis
前言 在前面的MyBatis部分内容中,我们已经可以独立的基于MyBatis构建一个数据库访问层应用,但是在实际的项目开发中,我们的程序不会这么简单,层次也更加复杂,除了这里说到的持久层,还有业务逻辑 ...
- Memcached理解笔2---XMemcached&Spring集成
一.Memcached Client简要介绍 Memcached Client目前有3种: Memcached Client for Java SpyMemcached XMemcached 这三种C ...
- 160530、memcached集群(spring集成的配置)
第一步:在linux机或windows机上安装memcached服务端(server) linux中安装memcached:centos中命令 yum -y install memcached 如果没 ...
- Spring与Struts2集成开发
Struts2和Spring都是不错的开源框架,Spring与Struts2集成开发,把二者结合在一起使用,开发效果更佳,效率杠杠的.下面介绍一下如何将Spring与Struts2集成在一起开发.分七 ...
随机推荐
- Jenkins 插件加速下载
本文主旨 看到好多加速Jenkins安装插件速度的文章,大多数教程中都是在插件配置里使用 https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/up ...
- Java实现单例的5种方式
1. 什么是单例模式 单例模式指的是在应用整个生命周期内只能存在一个实例.单例模式是一种被广泛使用的设计模式.他有很多好处,能够避免实例对象的重复创建,减少创建实例的系统开销,节省内存. 2. 单例模 ...
- OpenResty之 lua_shared_dict 指令
1. lua_shared_dict 指令介绍 原文: lua_shared_dict syntax:lua_shared_dict <name> <size> default ...
- sqlserver 锁表进程及执行的SQL
--1.查进程select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) tableNamefrom sys.d ...
- jmeter-Charles抓包显示的请求方式错误了,难道
抓包显示的请求方式为get,但是get一直报错见上图 将get修改为post就正确了
- linux下mysql下载安装
1.下载地址 https://www.mysql.com/downloads/ 选择community server 点击DOWLOAD 选择版本,当前选择的5.6版本 点击下载mysql-5.6. ...
- 安装Oracle11g出现INS-13001环境不满足最低要求
原版:https://blog.csdn.net/Q_Sea__/article/details/79012808 第一次安装Oracle11g,就出现这个问题,就找了一些解决方案.现在总结一下. 出 ...
- python 时间对比
import datetimed1 = datetime.datetime.strptime('2015-03-05 17:41:20', '%Y-%m-%d %H:%M:%S')d2 = date ...
- LeetCode_9. Palindrome Number
9. Palindrome Number Easy Determine whether an integer is a palindrome. An integer is a palindrome w ...
- leetcode 将一个二维矩阵进行90度旋转
import numpy as np import math if __name__ == '__main__': def rotate(matrix): n = len(matrix[0]) for ...