RE: [coldbox:15838] Re: [cachebox-latest] How to easily disable/reenable caching?

You can probably modify the black hole provider to return something for getting an object’s metadata, but what would you return? The black hole provider doesn’t actually store anything so there is no metadata. Perhaps you could hard code the provider to return a standard struct of dummy metatdata. Of course, I can’t guarantee that won’t cause issues if your app sets something into cache and then looks at its metadata and expects certain values.

There are limits to the behavior a dummy component can provide. You may have to just set some flag in your app which determines whether or not to use caching and check it every time. Either that, or your app will need to be written in such a way that it assumes the caching provider isn’t actually doing anything and never depends on it to function.



ColdBox Platform Evangelist
Ortus Solutions, Corp

ColdBox Platform:

A better way might be to use the onRequestCapture interception point – if a “no cache cookie” exists, do .

That will bypass the cache.


I agree with what you are saying, the black hole provider has no metadata to return. But it is returning metadata, and it is different than what the CFProvider returns. Here is the metadata from the CFProvider:

cache_hitcount: 16
cache_misscount: 6
createdtime: {ts '2012-08-20 17:29:12'}
hitcount: 4
idletime: 60
lasthit: {ts '2012-08-20 17:29:41'}
lastupdated: {ts '2012-08-20 17:29:12'}
name: OBJECT
size: 13552

Here is the metadata for the black hole provider:

CREATED: {ts '2012-08-20 17:35:18'}
LASTACCESSED: {ts '2012-08-20 17:35:22'}

So my code:

<cfif StructKeyExists(material,“cacheMetaData”)>
Cached since #TimeFormat(material.cacheMetaData.createdTime,“medium”)#

crashes since there is no createdTime property. I was thinking the black hole provider would return false for lookup(), but evidently its not. Here is some of my related code:

<cfif myCache.lookUp(cacheKey)>

Am I doing something wrong? Why is the black hole provider caching? Is it something I’m doing wrong with this code:

<cfset a_blackhole_cache = application.cacheBox.getCache(“a_blackhole_cache”) />
<cfset application.cacheBox.replaceCache(“mycache”, a_blackhole_cache) />

Maybe I’m declaring the cache incorrectly?

Thanks for your help.
Ryan Stille

Another odd thing is the data stays in the cache for a long time (forever?) even though on the report it shows an idle timeout of 1 and a timeout of 1.

When I cache my data I am specifying timeout outs of 1 minute. Which has worked correctly in the past, until I started messing with the blackhole object store.