simple-spring-memcached统一缓存的使用实例2

 

spring配置说明

关于Simple-Spring-Memcached具体XML配置如下:

<beans xmlns="http://www.springframework.org/schema/beans"

       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"

       xmlns:context="http://www.springframework.org/schema/context"

       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd

       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

 

    <import resource="classpath:simplesm-context.xml"/>

 

    <aop:aspectj -autoproxy/>

    <context:annotation -config/>

 

    <bean name="appCache" 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">

                <!--memcached服务器ip:port 可以是多个,格式为: 127.0.0.1:11211,192.168.100.11:11211-->

                <property name="address" value="{memcached.server}"/>

            </bean>

        </property>

        <property name="configuration">

            <!-- memcached连接器的配置,具体的配置项参考这个类 -->

            <bean class="com.google.code.ssm.providers.XMemcachedConfiguration">

                <!--是否使用一致性哈希-->

                <property name="consistentHashing" value="true"/>

                <!--连接池-->

                <property name="connectionPoolSize" value="10"/>

                <property name="optimizeGet" value="true"/>

             </bean>

        </property>

        <property name="cacheName">

            <!-- 该Memcached配置的Cache名称 一个应用中存在多个Memcached时,各个配置的cacheName必须不同。如果该值未设,系统默认为default -->

            <value>appCache</value>

        </property>

    </bean>

</beans>

后续阅读下片博文

posted @ 2013-01-25 10:22  最轻  阅读(523)  评论(0编辑  收藏  举报