hi,everybody!
My match is spring mvc + mybatis + shiro , The version of jar is simple-spring-memcached-3.0.2
, xmemcached-1.3.8 , xmemcached-provider-3.0.2 ,
mybatis-memcached-1.0.0-beta1.jar.
The XML configuration:
mapper.xml(mybatis) : <mapper namespace="Account">
<cache
type="org.mybatis.caches.memcached.MemcachedCache" />
Configuration.xml(mybatis) : <setting name="cacheEnabled"
value="true" />
applicationContext.xml(spring): <import
resource="classpath:simplesm-context.xml" />
<aop:aspectj-autoproxy />
<bean
name="defaultMemcachedClient" class="com.google.code.ssm.CacheFactory">
<property name="cacheName" value="defaultCache" />
<property name="cacheClientFactory">
<bean name="cacheClientFactory"
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>
I didn't set on a UserMyBatisDaoImp proxy, but on the service, because
UserMyBatisDaoImp extends SqlSessionDaoSupport ,
So, my service is used like this:
@ReadThroughMultiCache(namespace = "user", expiration = 600, option =
@ReadThroughMultiCacheOption(generateKeysFromResult = true))
public List<User> getAllUser(@ParameterValueKeyProvider final
List<Long> ids) {
return (List<User>) mybatisDao.selectList();
}
I just want to query a collection of all, don't want to incoming parameters
,so the Controller be used like this:
List<Long> ids= Arrays.asList(1L, 2L);
List<User> users =accountManager.getAllUser(ids);
I set the @CacheKeyMethod or not,or set service like this:
@ReadThroughMultiCache(namespace = "user", expiration = 600)
public List<User> getAllUser(@ParameterValueKeyProvider final
List<Long> ids) {
return (List<User>) mybatisDao.selectList();
}
Memcached does not run set / get , Always perform a database query .
The log4j content of the output is only xmemcached heartbeat messages.
I have no idea, ask everybody to help, thank you very much !!