我知道我可以使用ColdFusion缓存API清除数据:

<cfset cacheName = "custom">
<cfset ids = cacheGetAllIds(cacheName)>
<cfset cacheRemove(arrayToList(ids), false, cacheName)>

但是实际上检索所有ID(即 cacheGetAllIds())要删除很慢(例如秒)。我认为如果我完全开始以毫秒为单位,应该有一种方法。在我的特殊情况下,自定义缓存是磁盘持续存在的,可以是磁盘上的100兆字节。

我怀疑有一种更快的方法可以使用方法清除此方法 cacheGetSession(), ,也许与ColdFusion Apis结合使用。因此,要求查看某人是否知道如何做到这一点, 在我自己开始看着引擎盖之前,让ColdFusion同时快乐。

更新

看起来可能可以使用 cachegetsession(cachename,true).removeall(),因为返回的对象是类型 net.sf.ehcache.cache, ,实施 net.sf.ehcache.ehcache. 。并且此接口指定方法removeAll()。尚未尝试过。

有帮助吗?

解决方案

这样做:

cacheGetSession(cacheName, true).removeAll()

大约有10k+记录,它在60毫秒内返回。

仅供参考:cachgetsession()是冷灌注9.0.1功能

其他提示

我还没有测试过,但是这更快吗?以防万一 ArrayToList() 是瓶颈。

<cfloop index="cache" array="#cacheGetAllIds(cacheName)#">
    <cfset cacheRemove(cache, false, cacheName)>
</cfloop>

参考: http://www.aaronwest.net/blog/index.cfm/2009/11/11/14-days-of-caching-9-caching-9-caching-day-12-12--rememoving-moving-almoving-all-items-in-cache

如果性能真的是您的问题,请提交错误报告? http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top