我正在开发一个带有模块的 ColdBox 应用程序,并希望使用它的缓存功能来缓存视图一段时间。
component{
property name="moduleConfig" inject="coldbox:moduleConfig:mymodule";
...
function widget(event, rc, prc){
var viewData = this.getData();
return renderView(
view = "main/widget",
args = viewData,
cache = true,
cacheSuffix = ":" & moduleConfig.entryPoint,
cacheTimeout = 2
);
}
}
我尝试通过将以下信息添加到我的 Cachebox.cfc 来设置默认缓存配置,并cacheTimeout
从上面的代码中删除:
cacheBox = {
defaultCache = {
objectDefaultTimeout = 1, //two hours default
objectDefaultLastAccessTimeout = 1, //30 minutes idle time
useLastAccessTimeouts = false,
reapFrequency = 5,
freeMemoryPercentageThreshold = 0,
evictionPolicy = "LRU",
evictCount = 1,
maxObjects = 300,
objectStore = "ConcurrentStore", //guaranteed objects
coldboxEnabled = false
},
caches = {
// Named cache for all coldbox event and view template caching
template = {
provider = "coldbox.system.cache.providers.CacheBoxColdBoxProvider",
properties = {
objectDefaultTimeout = 1,
objectDefaultLastAccessTimeout = 1,
useLastAccessTimeouts = false,
reapFrequency = 5,
freeMemoryPercentageThreshold = 0,
evictionPolicy = "LRU",
evictCount = 2,
maxObjects = 300,
objectStore = "ConcurrentSoftReferenceStore" //memory sensitive
}
}
}
};
虽然这对缓存没有任何影响。我还尝试将上面的配置添加到我的 Coldbox.cfc 中。
即使我通过 CommandBox via 创建了一个全新的测试应用程序coldbox create app MyApp
,然后仅将 Cachebox.cfc 中的缓存设置为一分钟,viewCaching = true
在 Coldbox.cfc 中设置并在 Main.cfc 中设置event.setView( view="main/index", cache=true )
,它也无法按预期工作。
无论我做什么,视图总是被缓存至少 5 分钟。
有什么我想念的吗?