我正在开发一个带有模块的ColdBox应用程序,并希望使用它的缓存功能来缓存视图一段时间。为什么ColdBox应用程序中renderView()的cacheTimeout设置不起作用?
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中。
即使我通过coldbox create app MyApp
通过CommandBox创建一个完全新的测试程序,然后只设置在Cachebox.cfc的缓存为1分钟,在Coldbox.cfc设置viewCaching = true
,并在Main.cfc设置event.setView(view="main/index", cache=true)
,它不没有按预期工作。
无论我做什么,该视图总是缓存至少5分钟。
有什么我失踪?
您如何确认视图被缓存的时间? –
由于这个问题是在CFML松散团队中交叉发布的,我已经在那里回复(我无法复制)。一旦我们找出你的问题,我们可以回来更新答案,因为SO非常适合来回问与答。 –