memcached usage
Posted xiaobin-hlj80
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了memcached usage相关的知识,希望对你有一定的参考价值。
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>
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>
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 }
以上是关于memcached usage的主要内容,如果未能解决你的问题,请参考以下文章