NutzCN Logo
问答 daocache缓存逻辑是怎么样的?为啥单表查询也没缓存。
发布于 2494天前 作者 zp8821138 1644 次浏览 复制 上一个帖子 下一个帖子
标签:

日志是

[DEBUG] 2018-02-24 08:49:08,469 org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:148) - sql = SELECT m.id,m.parentId,(SELECT p.name from sys_menu p WHERE p.id = m.parentId) as parentName,m.name,m.href,m.permission,m.type,m.icon,m.location from sys_menu m where 1 = 1 ORDER BY m.location ASC, tables = [sys_menu, sys_menu]
[DEBUG] 2018-02-24 08:49:08,470 org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:178) - not good for cache >> SELECT m.id,m.parentId,(SELECT p.name from sys_menu p WHERE p.id = m.parentId) as parentName,m.name,m.href,m.permission,m.type,m.icon,m.location from sys_menu m where 1 = 1 ORDER BY m.location ASC
[DEBUG] 2018-02-24 08:49:08,470 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - SELECT m.id,m.parentId,(SELECT p.name from sys_menu p WHERE p.id = m.parentId) as parentName,m.name,m.href,m.permission,m.type,m.icon,m.location from sys_menu m where 1 = 1 ORDER BY m.location ASC
[DEBUG] 2018-02-24 08:49:08,694 com.kanq.processor.LogTimeProcessor.process(LogTimeProcessor.java:22) - [GET ]URI=/sjw/platform/sys/menu/list 226ms

并没有做增删改的操作,就是重复查询,貌似没有进行缓存,同表关联查询也不能缓存吗?

8 回复

配置文件中对sys_menu做了缓存,配置文件如下

cacheExecutor : {
		type : "org.nutz.plugins.cache.dao.DaoCacheInterceptor",
		fields : {
			DEBUG:true
			cacheProvider : {refer:"cacheProvider"},
			cachedTableNames : ["sys_user", "sys_role", "sys_menu","cms_category"]
		}
	}

仅缓存单表查询

自定义sql没办法缓存,像这种生成菜单树的其实应该按照道理变化不大的 需要缓存有啥办法木有啊

自定义sql也能缓存,但daocache当前只支持缓存单表的查询

变化不大?用LruCach类就行啦

有文档吗。。

LruCache类的源码即文档

添加回复
请先登陆
回到顶部