`
tom_seed
  • 浏览: 318634 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

Spring集成memcache(二)xmemcache

 
阅读更多

xmemcache是国内开发的jar包,,与Spring集成也比较简单,步骤如下:

1.添加xmemcache.jar包至工程中;

2.在web.xml文件中添加配置

	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>
			/WEB-INF/conf/spring/*-beans.xml
		</param-value>
	</context-param>

 

 

3.在属性文件中添加如下配置:

#memcache配置
memcache.ip=127.0.0.1
memcache.port=11211
memcache.pool.size=5

 

 

4.在/WEB-INF/conf/spring/目录下添加配置文件memcache-beans.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cache="http://www.springframework.org/schema/cache"
	xsi:schemaLocation="  
        http://www.springframework.org/schema/beans  
        http://www.springframework.org/schema/beans/spring-beans-3.2.xsd  
        http://www.springframework.org/schema/cache  
        http://www.springframework.org/schema/cache/spring-cache-3.2.xsd"
	default-autowire="byName">

	<bean id="memcachedClientBuilder" class="net.rubyeye.xmemcached.XMemcachedClientBuilder">
		<constructor-arg>
			<list>
				<bean class="java.net.InetSocketAddress">
					<constructor-arg value="${memcache.ip}" />
					<constructor-arg value="${memcache.port}" />
				</bean>
			</list>
		</constructor-arg>
		<property name="connectionPoolSize" value="${memcache.pool.size}" />
		<property name="commandFactory">
			<bean class="net.rubyeye.xmemcached.command.BinaryCommandFactory" />
		</property>
		<property name="transcoder">
			<bean class="net.rubyeye.xmemcached.transcoders.SerializingTranscoder" />
		</property>
	</bean>

	<bean id="memcachedClient" factory-bean="memcachedClientBuilder"
		factory-method="build" destroy-method="shutdown" />
</beans>

 

 

5.在Action中测试代码如下:

@RequestMapping(value = "/index")
	public void index(HttpServletRequest request, ModelMap model) throws TimeoutException, InterruptedException, MemcachedException{
		List<FmSupplier> list = supplierManager.getEnableSuppliers();
		memcachedClient.add("list", 0, list);
	}
	
	@RequestMapping(value = "/show")
	public void show(HttpServletRequest request, ModelMap model) throws TimeoutException, InterruptedException, MemcachedException{
		List<FmSupplier> listTemp = (List<FmSupplier>) memcachedClient.get("list");
		for(FmSupplier temp :listTemp)
			System.out.println(temp.getLinkman());
	}

 

以下是xmemcache.jar包

分享到:
评论

相关推荐

    spring memcache 集成使用

    spring与memcache的开发配置!很详细

    memcache也spring,hibernate的配置

    memcache的客户端,用maven构建,里有用hibernate-memcached与hibernate,spring3.0进行配置,也有与spring3.0单独配置。

    spring_memcache

    本人亲自搭建的spring和memcache缓存的项目,项目中说明也很详细,用的是oracle数据库。要是下载着使用的是其他数据库相信你也能快速改用,也可以在service层直接返回数据。目的在于怎么使用memcache。使用之前麻烦...

    xmemcache与SPRING整合

    如何基于Spring进行配置memcache及开发使用

    maven-spring-memcache

    spring整合memcache,测试缓存数据库的增删改查。

    simple-spring-memcached集成memcache

    NULL 博文链接:https://younglibin.iteye.com/blog/2157666

    Memcache+spring+ibatis例子,包含单纯memcache例子

    包含最简单的memcache的使用,测试类MemCached.java; 在此基础上增加了memcahce和spring的整合,顺便使用了ibati,测试类SpringMemcacheTest.java 代码简洁,适合研究,参考

    spring memcache mybatis

    spring memcache mybatis 从网上下载的 能跑起来 可以试一下

    springmvc配置Memcache缓存Demo

    springmvc框架配置Memcache缓存示例,使用者需要自己修改db.properties中的memcache缓存服务地址,修改正确地址后可直接运行

    win nginx php mysql memcache集成环境

    php mysql nginx memcache集成环境

    memcache实现网站全局计数器

    memcache实现网站全局计数器 xmemcache counter

    spring-memcache-sample:示例 Spring 项目,使用基于 memcached 的缓存后端缓存注释

    Spring Memcache 示例一个开箱即用的小示例,用于演示在 Spring MVC 驱动的 REST API 上使用 Spring 的@Cache注释。使用的库以下是演示中使用的最重要库的列表: 图书馆版本评论弹簧框架4.1.2. 发布弹簧芯弹簧数据-...

    memcache图形监控工具phpmemcache

    memcache图形监控工具phpmemcache,尽是一个PHP文件就可以实现对memcache的监控。 使用方法:本地测试监控机安装Apache或者下载XAMPP(Apache+MySQL+PHP+PERL),安装后把memcachephp.zip中的memcache.php文件放到...

    memcache1.2.1 for windows

    windows下memcache安装包 附带php扩展包

    最新windows版php_memcache.dll和memcache.exe

    最新windows的memcache模块下载 这个模块是平和php5.3的,在我的windowsxp php5.3.5上安装成功 里面有两个php库,一个php_memcache.dll.vc6 和一个php_memcache.dll.vc9 另外一个windows的memcache.exe文件,都是网上...

    memcache安装包,memcache

    memcache是一套分布式的高速缓存系统,由LiveJournal的Brad Fitzpatrick开发,但目前被许多网站使用以提升网站的访问速度,尤其对于一些大型的、需要频繁访问数据库的网站访问。

    Memcache完全剖析 最实用的Memcache文档

    Memcache就不用多介绍了,做开发的人都知道。 但要用得好,却并不是那么容易的事。 如果用得不好,反而得不偿失。 这篇文档短小精悍,囊括了使用过程中需要要注意的方方面面。值得一读。

    MemCache开发说明文档

    Memcache是一个高性能的分布式的内存对象缓存系统,通过在内存里维护一个统一的巨大的hash表,它能够用来存储各种格式的数据,包括图像、视频、文件以及数据库检索的结果等。简单的说就是将数据调用到内存中,然后从...

    delphi memcache MemCache.0.2.0.zip

    MemCache.0.2.0.zip Memcached Client for Delphi 客户端调用类 MemCache.0.2.0.zip Show all LinksExternal links Memcached Project This project is a delphi unit which implements a thread safe client for ...

Global site tag (gtag.js) - Google Analytics