Closed GoogleCodeExporter closed 9 years ago
You're defining cache with custom cache's name: slfV5_Cache.
You may:
1. remove <property name="cacheName" value="slfV5_Cache" /> so the cache will
have default name
or
2. use annotation @CacheName("slfV5_Cache") on each method annotated with SSM
annotations: @ReadThrough*, @Update*, @Invalidate*, in the case on
com.zxhz.web.TestController.testssm
Original comment by ragno...@gmail.com
on 13 Dec 2012 at 4:49
thanks !
but today ,the project runing with tomcat . the cache is invalid!
xml :
<context:component-scan base-package="zt.ssmt"/>
<aop:aspectj-autoproxy/>
<mvc:annotation-driven/>
<import resource="classpath:simplesm-context.xml" />
<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.spymemcached.MemcacheClientFactoryImpl" />
</property>
<property name="addressProvider">
<bean class="com.google.code.ssm.config.DefaultAddressProvider">
<property name="address" value="192.168.1.62:11211" />
</bean>
</property>
<property name="configuration">
<bean class="com.google.code.ssm.providers.CacheConfiguration">
<property name="consistentHashing" value="true" />
</bean>
</property>
</bean>
code:
@RequestMapping("/")
public void con(){
for (int i = 0; i < 5; i++) {
log.info(ssm());
}
}
@ReadThroughAssignCache(assignedKey="zhang",expiration=3600,namespace="zhang")
public String ssm(){
log.info("run one");
return "run any";
}
console:
.............
2012-12-14 10:57:29.237 INFO net.spy.memcached.MemcachedConnection: Added {QA
sa=/192.168.1.62:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null,
toWrite=0, interested=0} to connect queue
2012-12-14 10:57:29.253 INFO net.spy.memcached.MemcachedConnection: Connection
state changed for sun.nio.ch.SelectionKeyImpl@6f156508
...............
[2012-12-14 10:57:37 0333 INFO ] [http-80-2] zt.ssmt.SsmtComtroller - run one
[2012-12-14 10:57:37 0333 INFO ] [http-80-2] zt.ssmt.SsmtComtroller - run any
[2012-12-14 10:57:37 0333 INFO ] [http-80-2] zt.ssmt.SsmtComtroller - run one
[2012-12-14 10:57:37 0333 INFO ] [http-80-2] zt.ssmt.SsmtComtroller - run any
[2012-12-14 10:57:37 0333 INFO ] [http-80-2] zt.ssmt.SsmtComtroller - run one
[2012-12-14 10:57:37 0333 INFO ] [http-80-2] zt.ssmt.SsmtComtroller - run any
[2012-12-14 10:57:37 0333 INFO ] [http-80-2] zt.ssmt.SsmtComtroller - run one
[2012-12-14 10:57:37 0333 INFO ] [http-80-2] zt.ssmt.SsmtComtroller - run any
[2012-12-14 10:57:37 0333 INFO ] [http-80-2] zt.ssmt.SsmtComtroller - run one
[2012-12-14 10:57:37 0333 INFO ] [http-80-2] zt.ssmt.SsmtComtroller - run any
i don't know where is error!
Original comment by fengsezh...@gmail.com
on 14 Dec 2012 at 2:59
The error is self invocation, invoking ssm() method in con() method using
'this' reference (the same object). Spring doesn't intercept self invocations,
such invocation omits proxy so the SSM is not invoked. Move ssm() method to
another bean: MyCache and inject the bean to bean with con() method.
Original comment by ragno...@gmail.com
on 14 Dec 2012 at 6:34
so!
This method has four parameters!
method :
public Object getSpec(int merId,String code,int type,httpservletrequest
request){
//TODO
}
I want to use the three parameter as cache key
What should I do?
Thank you very much! thanks a lot!
Original comment by fengsezh...@gmail.com
on 14 Dec 2012 at 7:02
To create cache key using many parameters use @ParameterValueKeyProvider
annotation:
@ReadThroughSingleCache(namespace = "spec", expiration = 3600)
public Object getSpec(@ParameterValueKeyProvider(order = 0) int merId,
@ParameterValueKeyProvider(order = 1) String code,
@ParameterValueKeyProvider(order = 2) int type,httpservletrequest request){
//TODO
}
Original comment by ragno...@gmail.com
on 14 Dec 2012 at 7:14
Thank you very much indeed.
It’s very kind of you.
Original comment by fengsezh...@gmail.com
on 14 Dec 2012 at 7:23
No problem :).
Next time please use SSM's mailing group:
http://groups.google.com/group/simple-spring-memecached
Best regards,
Ragnor
Original comment by ragno...@gmail.com
on 14 Dec 2012 at 7:31
Original issue reported on code.google.com by
fengsezh...@gmail.com
on 13 Dec 2012 at 11:45