NutzCN Logo
问答 只想用DaoCache缓存2个表的内容 请问该怎么操作
发布于 783天前 作者 Howe 339 次浏览 复制 上一个帖子 下一个帖子
标签: cache dao

nutzbook 里面 我记得有个 读取配置的章节没了?
还有 DaoCache 我只想用来缓存2个表的内容 请问该怎么操作

2 回复

读取配置? 不知道你指哪个

cacheExecutor : {
			type : "org.nutz.plugins.cache.dao.CachedNutDaoExecutor",
			fields : {
				cacheProvider : {refer:"cacheProvider"},
				cachedTableNames : [ // 任意N个表
				                    "t_user_profile",
				                    "t_user", "t_role", "t_permission", "t_role_permission",
				                    "t_topic", "t_topic_reply",
				                    "t_oauth_user"
				                    ],
					//cachedTableNamePatten : ".+" // 也可以通过正则表达式来匹配
			}
		}

兽总已帮解决 贴dao.js配置

var ioc = {
dataSource: {
type: "com.alibaba.druid.pool.DruidDataSource",
events: {
depose: "close"
},
fields: {
driverClassName: 'com.mysql.jdbc.Driver',
url: 'jdbc:mysql://localhost:3306/ce?useUnicode=true&characterEncoding=UTF-8',
username: 'ce',
password: 'MVISEq/MWz7+TPts1m5aW9k6/zeIK2dhOzQ3LkkIURs+pIaIBGvEQpb9QQDlrqvx5zzt8wlyHM+GyEUramNoaw==',
initialSize: 1,
maxActive: 500,
minIdle: 1,
filters: 'config',
connectionProperties: 'config.decrypt=true',
defaultAutoCommit: false,

        //validationQueryTimeout : 5,
        validationQuery: "select 1"
    }
},
dao: {
    type: "org.nutz.dao.impl.NutDao",
    args: [{refer: "dataSource"}],
    fields: {
        executor: {refer: "cacheExecutor"}
    }
},
cacheExecutor: {
    type: "org.nutz.plugins.cache.dao.CachedNutDaoExecutor",
    fields: {
        cacheProvider: {refer: "cacheProvider"},
        cachedTableNames: [ // 任意N个表
            "tb_chanyue_1",
            "tb_chanyue_2",
            "tb_chanyue_help_3"
        ],
        //cachedTableNamePatten : ".+" // 也可以通过正则表达式来匹配
    }
},
cacheProvider: {
    type: "org.nutz.plugins.cache.dao.impl.provider.MemoryDaoCacheProvider",
    fields: {
        cacheSize: 10000 // 缓存的对象数
    },
    events: {
        create: "init"
    }
}

};

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