[coldbox-3.5.2] Event Caching and Dynamic Variables

Hi - I use view caching often, but just started using Event caching. I like to set several variables in my Coldbox.cfc settings for production/dev/etc. so that I can programmatically turn things (like caching) on and off to test.

This is very easy to do in a granular way with view caching by setting a dynamic boolean variable to the cache=“true” statement. However, Event caching is only setup - as far as I can tell - in the method declaration, either inline or in the javadoc-style comments (I am using script-based CFC’s only). I do not believe that one can have a dynamic variable in this position? (at least I certainly couldn’t make it work!) My guess is that this is because the methods need to be compiled first before they can run and evaluate the variable?

I realize that I can turn Event caching on/off globally in Colbox.cfc, but in light of the above limitation, is there any way to do so on a more granular level either within Coldbox or in a CFML way around the dynamic variable in a method declaration issue listed above?

It’s not the end of the world if I cannot do this, but thought I’d ask here for some advice!

Andy

http://www.andyscott.id.au/2011/4/15/Setting-up-your-ColdBox-30-application-for-development-and-production

Thank you Andrew, but perhaps I did not explain myself properly. I completely understand how to setup production/dev/staging/etc. environments via the Coldbox.cfc file.

Specifically, Event caching can be GLOBALLY set to be true/false in this file, but there does not seem to be a way to set this up programmatically so that some events are cached but others are not, depending on the environment (or depending upon any programmatic, dynamic variable).

As an example, for view caching, I can set a list of flags in the settings of Coldbox config and then when setting the view, I can do something like this in a layout or view:

renderView(view=‘viewlets/standingsPod’,cache=getSetting(‘CacheViews’),cacheTimeout=‘600’)

or in a handler:
event.setView( name=“schedule”, cache=getSetting(‘CacheViews’), cacheTimeout=‘600’ );

where ‘CacheViews’ is a boolean set in a particular environment.

However - as far as I can tell - in order to cache an EVENT, the cache=true, cacheTimeout=‘600’ attributes can only be set in the method declaration metadata (either inline or in the javadoc style comments). CFML does not allow for dynamic variable evaluation in these 2 places.

I hope that makes more sense as to what I am asking?

Thanks,
Andy

Ok, sorry I see what you are saying now… Will have to have a look, but from the days before cacheBox there used to be attributes for the handlers, so hopefully they still work. Never used it, so not sure it is exactly what you’re looking for.