配置
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<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>127.0.0.1:11211</value>
</list>
</property>
<property name="initConn">
<value>20</value>
</property>
<property name="minConn">
<value>10</value>
</property>
<property name="maxConn">
<value>50</value>
</property>
<property name="maintSleep">
<value>30</value>
</property>
<property name="nagle">
<value>false</value>
</property>
<property name="socketTO">
<value>3000</value>
</property>
</bean>
<bean id="memcachedClient" class="com.danga.MemCached.MemCachedClient">
<constructor-arg>
<value>neeaMemcachedPool</value>
</constructor-arg>
<property name="compressEnable">
<value>true</value>
</property>
<property name="compressThreshold">
<value>4096</value>
</property>
</bean>
</beans>
使用
public static MemCachedClient memcachedClient = (MemCachedClient) SpringHelper.getBean("memcachedClient");
List
ebeans;
注入和得到内存数据
memcachedClient.set("ebeans",*****Service.getObjects(****));
ebeans = (List) memcachedClient.get("ebeans");
注意:set到memcached当中的对象必须是 java.io.Serializable 的 序列化的model
否则list为空