持久层使用Ibatis,并开启动缓存
后台画面可用如下代码强制刷新(根据缓存ID来刷新,不传递缓存参数时,刷新所有缓存)
1. // spring注入
2. private
3.
4. public
5. return
6. }
7.
8. public void
9. this.sqlMapClient = sqlMapClient;
10. }
11.
12. public
13. throws
14. new String[] { "TBL_SELL.oneDayCache"
15.
16. // 刷新指定缓存
17. if (cacheModelIds.length > 0) {
18. for
19. sqlMapClient.flushDataCache(cacheModelId);
20. }
21. else
22. // 刷新所有缓存
23. sqlMapClient.flushDataCache();
24. }
25. return null;
26. }
// spring注入
private SqlMapClient sqlMapClient;
public SqlMapClient getSqlMapClient() {
return sqlMapClient;
}
public void setSqlMapClient(SqlMapClient sqlMapClient) {
this.sqlMapClient = sqlMapClient;
}
public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
String[] cacheModelIds = new String[] { "TBL_SELL.oneDayCache" };
// 刷新指定缓存
if (cacheModelIds.length > 0) {
for (String cacheModelId : cacheModelIds) {
sqlMapClient.flushDataCache(cacheModelId);
}
} else {
// 刷新所有缓存
sqlMapClient.flushDataCache();
}
return null;
}
输出日志
- 13:57:44,250 DEBUG CacheModel:27 - Cache 'TBL_SELL.oneDayCache': flushed