码迷,mamicode.com
首页 > 系统相关 > 详细

memcached usage

时间:2018-05-02 02:30:49      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:cto   分享   mave   ret   SM   artifact   version   def   service   

 

https://github.com/ragnor/simple-spring-memcached/wiki/Getting-Started

 

1) maven

技术分享图片
<dependency>
  <groupId>com.google.code.simple-spring-memcached</groupId>
  <artifactId>spymemcached-provider</artifactId>
  <version>4.0.0</version>
</dependency>
spymemcached

 

2) applicationContext.xml

技术分享图片
<import resource="simplesm-context.xml" />
    <aop:aspectj-autoproxy />
    
    <bean name="defaultMemcachedClient" class="com.google.code.ssm.CacheFactory">
        <property name="cacheClientFactory">
          <bean name="cacheClientFactory" class="com.google.code.ssm.providers.spymemcached.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>
spring config xml(part)

 

3) service

技术分享图片
1     @Override
2     @ReadThroughSingleCache(namespace = "carnum", expiration = 300)
3     public List<TrainOrder> getCarList(String year, String month, @ParameterValueKeyProvider int trainNumber) {
4         // TODO Auto-generated method stub
5         return trainOrderDao.getCarnumberList(year, month, trainNumber);
6     }
TrainOrderServiceImpl.java(part)

 

memcached usage

标签:cto   分享   mave   ret   SM   artifact   version   def   service   

原文地址:https://www.cnblogs.com/xiaobin-hlj80/p/8977854.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!