springmemcachedsimple-spring-memcachedssm

spring-simple-memcache - maven dependencies for ReadThroughSingleCache


Has anyone used spring simple memcached? I have not been able to get the exact maven dependency and the repository where this is available. The dependencies mentioned on the code.google page (http://code.google.com/p/simple-spring-memcached/) mention other dependencies but it does not include jar for Simple-spring-memcache itself.

Thanks for the help guys.


Solution

  • In case of SSM 2.0.0 you need also memcached client (xmemcached or spymemcached):

    <dependency>
        <groupId>com.google.code.simple-spring-memcached</groupId>
        <artifactId>simple-spring-memcached</artifactId>
        <version>2.0.0</version>
    </dependency>
    <dependency>
        <groupId>com.googlecode.xmemcached</groupId>
        <artifactId>xmemcached</artifactId>
        <version>1.3.5</version>
    </dependency> 
    

    and configure connection to local memcached server:

    <beans xmlns="http://www.springframework.org/schema/beans" 
        xmlns:aop="http://www.springframework.org/schema/aop"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                http://www.springframework.org/schema/aop
                http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
    
        <import resource="simplesm-context.xml" />
        <aop:aspectj-autoproxy />
    
        <bean name="defaultMemcachedClient" class="com.google.code.ssm.CacheFactory">
              <property name="cacheClientFactory">
                    <bean class="com.google.code.ssm.providers.xmemcached.MemcacheClientFactoryImpl" />
              </property>
              <property name="addressProvider">
                    <bean class="com.google.code.ssm.config.DefaultAddressProvider">
                         <property name="address" value="127.0.0.1:11211" />
                    </bean>
              </property>
              <property name="configuration">
                    <bean class="com.google.code.ssm.providers.CacheConfiguration">
                          <property name="consistentHashing" value="true" />
                    </bean>
              </property>
         </bean>
    </beans>