NutzCN Logo
问答 nutzwk中一级缓存和二级缓存是针对于shiro的?
发布于 2218天前 作者 zp8821138 1430 次浏览 复制 上一个帖子 下一个帖子
标签:

我的理解是默认只缓存了session,没有其他用途吗? 感觉这样是不是有点浪费啊 搞这么大就缓存session。。 daocache是缓存单表查询的? 然后wkcache是可以缓存对象的?不知道这样理解是不是有问题

5 回复

那是lcache的一部分,通过LcacheManager可以拿到Cache实例,从而缓存任意东西

daocache当前只能缓存单表

wkcache专注于方法级的缓存

你是想统一起来吧?

只要没搞懂为啥要有这么几种,wkcache专注于方法级的缓存 也是缓存查询结果的把,daocache也是缓存查询结果,LcacheManager也是一般用于缓存查询结果的把,为啥分成三份 ,统一起来感觉更好理解。

jedisAgent = org.nutz.integration.jedis.JedisAgent
cacheManager_ehcache = org.apache.shiro.cache.ehcache.EhCacheManager
cacheManager_ehcache.cacheManagerConfigFile=classpath:ehcache.xml
cacheManager_redis = org.nutz.plugins.cache.impl.redis.RedisCacheManager
cacheManager_redis.mode=kv
cacheManager_redis.debug=true
cacheManager = org.nutz.plugins.cache.impl.lcache.LCacheManager
cacheManager.jedisAgent = $jedisAgent
cacheManager.level1 = $cacheManager_ehcache
cacheManager.level2 = $cacheManager_redis

nutzwk中感觉ehcache啥用一样 百度说是能做页面级缓存 貌似也没用到

// 基于Ehcache的DaoCacheProvider
		cacheProvider : {
			type : "org.nutz.plugins.cache.dao.impl.provider.EhcacheDaoCacheProvider",
			fields : {
				cacheManager : {refer:"cacheManager"} // 引用ehcache.json中定义的CacheManager
			},
			events : {
				create : "init"
			}
		}
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="false"
    monitoring="autodetect" dynamicConfig="true" name="nutzwk">
    <diskStore path="ehcache.disk.store.dir/nutzwk"/>
    <cache name="shiro-activeSessionCache"
           maxElementsInMemory="1000"
           overflowToDisk="true"
           eternal="true"
           timeToLiveSeconds="0"
           timeToIdleSeconds="0"
           diskPersistent="true"
           diskExpiryThreadIntervalSeconds="600"/>

    <defaultCache maxElementsInMemory="10000" eternal="false"
                  timeToIdleSeconds="86400" timeToLiveSeconds="86400" overflowToDisk="false"
                  diskPersistent="false" diskExpiryThreadIntervalSeconds="120"
                  statistics="false" />
</ehcache>

// 引用ehcache.json中定义的CacheManager这句话是什么意思。而且为啥这里要用EhcacheDaoCacheProvider 没有像shiro那样有一级二级缓存 我看实现貌似是三种 redis ehcahce memory ,没有介乎redis和ehcache

因为没做好一个统一的cache组件。。。

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