请教高手,问题如下:/**
* 好友管理类
*/
public class FridServ{
//利用spring注解缓存用户的好友列表
@Cacheable(value="fridsCache",key="#uid")
public List<Frid> getFrids(long uid)
{
return DB.list("select * from frid where uid=?",uid);
} //这里调用上面方法的话,上面的缓存是没有效果的,除非到另外一个类中调用,何解?
public Frid getFrid(long uid,long buid)
{
List<Frid> frids=getFrids(uid);
for(Frid frid:frids){
...........
}
}
}为什么在同一个类中Spring Cache缓存失效了。
* 好友管理类
*/
public class FridServ{
//利用spring注解缓存用户的好友列表
@Cacheable(value="fridsCache",key="#uid")
public List<Frid> getFrids(long uid)
{
return DB.list("select * from frid where uid=?",uid);
} //这里调用上面方法的话,上面的缓存是没有效果的,除非到另外一个类中调用,何解?
public Frid getFrid(long uid,long buid)
{
List<Frid> frids=getFrids(uid);
for(Frid frid:frids){
...........
}
}
}为什么在同一个类中Spring Cache缓存失效了。
解决方案 »
- 请教:如何在Swing JTable的表头增加一个Check Box?
- java序列化
- 请教,如何让tomcat不支持spring框架
- 请教高手:如何根据Key取properties文件的Value程序?
- 高手请进~~急 ~在线等~
- 如何用JSP将XML数据动态的生成HTML树结构?
- 请问JBuilder下的tomcat起不来怎么办?
- 什末时候该关闭session?
- 改写一个Servlet就要重启一次Tomcat吗?真麻烦。
- ####一个J2EE功能分布问题,请高手指点#####
- java 电子子词典
- 【求助】要用javax.sql、sun.jdbc.odbc等,但src.zip中无对应java文件
Note
In proxy mode (which is the default), only external method calls coming in through the proxy are intercepted. This means that self-invocation, in effect, a method within the target object calling another method of the target object, will not lead to an actual caching at runtime even if the invoked method is ed with @Cacheable - considering using the aspectj mode in this case.