You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@RequestMapping(value = "demo1")
public UserBean demo1() {
UserService userService = new UserService();
return userService.getUser();
}
@Slf4j
public class UserService {
@HyCache(key = "user1", expire = 10)
public UserBean getUser(){
log.info("cache penetration");
return new UserBean("tom",18);
}
}
demo2
@RequestMapping(value = "demo2")
public UserBean demo2() {
return this.getUser();
}
@HyCache(key = "user2",expire = 10)
public UserBean getUser(){
log.info("cache penetration");
return new UserBean("tom",18);
}
demo3
@RequestMapping(value = "demo2")
public UserBean demo2(int userId) {
return this.getUser(userId);
}
@HyCache(key = "user:#userId",expire = 10)
public UserBean getUser(int userId){
log.info("cache penetration");
return new UserBean("tom",18);
}
About
HyCache is an open source caching tool.It is based on bytecode enhancement implementation, rather than spring's dynamic proxy. It can achieve a wider range of applications