问几个关于spymemcached的问题

穿越星辰 发布于 2013/04/17 14:52
阅读 2K+
收藏 0

使用net.spy.memcached.spring.MemcachedClientFactoryBean与Spring结合,MemcachedClient是在什么时候shutdown的?

配置:

<bean id="memcachedClient"
class="net.spy.memcached.spring.MemcachedClientFactoryBean">
<property name="servers" value="1.2.3.4:11211 1.2.3.5:11211" />
<property name="protocol" value="BINARY" />
<property name="transcoder">
<bean class="net.spy.memcached.transcoders.SerializingTranscoder">
<property name="compressionThreshold" value="1024"/>
</bean>
</property>
<property name="opTimeout" value="1000" />
<property name="timeoutExceptionThreshold" value="1998" />
<property name="hashAlg" value="KETAMA_HASH" />
<property name="locatorType" value="CONSISTENT" />
<property name="failureMode" value="Redistribute" />
<property name="useNagleAlgorithm" value="false" />
<property name="authDescriptor">
<bean class="net.spy.memcached.auth.AuthDescriptor">
<constructor-arg index="0">
<value>PLAIN</value>
</constructor-arg>
<constructor-arg index="1">
<bean class="net.spy.memcached.auth.PlainCallbackHandler">
<constructor-arg index="0">
<value>bucketName</value>
</constructor-arg>
<constructor-arg index="1">
<value>bucketNamePwd</value>
</constructor-arg>
</bean>
</constructor-arg>
</bean>
</property>
</bean>

Spring中配置的Bean是单例的吧,MemcachedClientFactoryBean每次都重新new一个MemcachedClient返回,但是这个MemcachedClient是啥时候关闭的呢?

难道是每次自己调用完某个操作后手动去shutdown?

比如:

public void set(String key,Object value){

MemcachedClient mc = (MemcachedClient)memcachedClient.getObject();

OperationFuture<Boolean> future = mc.set("Hello", 0, "OCS");

mc.shutdown();

}

这样会有神马问题吗?

加载中
0
e
eathfen
我也想问这个问题.. 最近在整合这玩意.. 请问楼主有什么解决方案了吗?
返回顶部
顶部