|
SpringIntegration
How to create a Spy MemcachedClient from Spring.
Featured, Phase-Implementation, Spring, Integration IntroductionCreating a MemcachedClient in a Spring ApplicationContext used to be somewhat hairy since the ConnectionFactoryBuilder isn't a JavaBean. This page describes how to create a MemcachedClient bean using the new MemcachedClientFactoryBean, (since version 2.6). UsageThe net.spy.memcached.spring.MemcachedClientFactoryBean creates a new instance of net.spy.memcached.MemcachedClient every time it is used. Here's a snippet of a typical bean definition: <bean id="memcachedClient" class="net.spy.memcached.spring.MemcachedClientFactoryBean">
<property name="servers" value="host1:11211,host2:11211,host3: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"/>
</bean>The MemcachedClientFactoryBean supports the same set of attributes as the net.spy.memcached.ConnectionFactoryBuilder and supplies the exact same semantics: ServersA string containing whitespace or comma separated host or IP addresses and port numbers of the form "host:port host2:port" or "host:port, host2:port". DaemonSet the daemon state of the IO thread (defaults to true). FailureModeSet the failure mode {Cancel | Redistribute | Retry} (defaults to Redistribute). HashAlgSet the hash algorithm (see net.spy.memcached.HashAlgorithm for the values). InitialObserversSet the initial connection observers (will observe initial connection). LocatorTypeSet the locator type {ARRAY_MOD | CONSISTENT} (defaults to ARRAY_MOD). MaxReconnectDelaySet the maximum reconnect delay. OpFactSet the operation factory. OpQueueFactorySet the operation queue factory. OpTimeoutSet the default operation timeout in milliseconds. ProtocolConvenience method to specify the protocol to use {BINARY | TEXT} (defaults to TEXT). ReadBufferSizeSet the read buffer size. ReadOpQueueFactorySet the read queue factory. ShouldOptimizeSet to false if the default operation optimization is not desirable (defaults to true). TranscoderSet the default transcoder (defaults to net.spy.memcached.transcoders.SerializingTranscoder). UseNagleAlgorithmSet to true if you'd like to enable the Nagle algorithm. WriteOpQueueFactorySet the write queue factory. AuthDescriptorSet the auth descriptor to enable authentication on new connections. |
Hi,
I am new to caching strategies; i just started using cache for our web application that is deployed on weblogic.
I would like to know few things :
1. what is memcache server, how to install it on my Weblogic.
2. what is the port that i need to use, my weblogic is running on 7001, host is localhost:
is the port is same as app server port ?
@Rafagopa
This is not really the appropriate place to ask that question, but here goes. 1) The server is named memcached, see this page: http://memcached.org/ 2) You can use any port you want, provided it is not already used by some other program. See this page for more details: http://code.google.com/p/memcached/wiki/NewConfiguringServer The server would be run with the following command "memcached -p 11212" to start on port 11212.
Hi,
The XML described above is slightly incorrect. If one attempts to set the HashAlg?, Spring throws an exception because it can't map the String, i.e.,
However, if you do this:
<property name="hashAlg"> <value type="net.spy.memcached.DefaultHashAlgorithm">KETAMA_HASH</value> </property>It works fine.
Hopefully that may help people out :-)
-=david=-
Does anyone know to create a memcached conn pool within spring to maintain N active memcached connections to same memcached server?