cached views

25 views
Skip to first unread message

adk

unread,
Jan 12, 2011, 6:41:29 PM1/12/11
to ColdBox Platform
Is there a way to turn off view caching for a dev environment?

I have tons of cached views similar to this sprinkled throughout an
application:

renderView(view='sections/
dspHeader',cache=true,cacheTimeout="1440")

and I would love to have an environment setting to turn off view
caching while on my dev machines in the same way we can do wioth event
and/or handler caching... but I cannot seem to find one other than
executing a clearAllViews() in each request?

Aaron Greenlee

unread,
Jan 12, 2011, 7:15:48 PM1/12/11
to col...@googlegroups.com
For development environment stuff, I often make a interceptor that is only registered within my dev environment. Then, you can clear the template cache at the start/end of each request.

Aaron Greenlee

unread,
Jan 12, 2011, 7:18:44 PM1/12/11
to col...@googlegroups.com
You can see an example of some dev-only stuff on this blog post: http://aarongreenlee.com/share/coldfusion-coldbox-client-source/

I have a snippet from my ColdBox config showing how to register an interceptor only in a specific environment.

You can read about clearing the items from the cache here: http://wiki.coldbox.org/wiki/CacheBox.cfm (clearAll()) for example.

adk

unread,
Jan 12, 2011, 7:52:25 PM1/12/11
to ColdBox Platform
Thanks Aaron - I'll give your blog post a lookover!

I think a config setting similar to the handler and event caching bool
would be a great addition to the configure API. By the way
getColdBoxOCM().clearAllViews() on onRequestStart does *not* seem to
work...

Luis Majano

unread,
Jan 12, 2011, 9:43:44 PM1/12/11
to col...@googlegroups.com
In ColdBox 3 we have two cache regions: default ( for objects and data) and template (views and event caching).  This provides flexibility to choose where items get stored and how and in what cache.  Therefore, to interact you are talking to the wrong provider.

getColdBoxOCM("template") or
getCacheBox().getCache("template")

Thanks

-- 
Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

On Wednesday, January 12, 2011 at 4:52 PM, adk wrote:

Thanks Aaron - I'll give your blog post a lookover!

I think a config setting similar to the handler and event caching bool
would be a great addition to the configure API. By the way
getColdBoxOCM().clearAllViews() on onRequestStart does *nott* seem to

work...

On Jan 12, 4:18 pm, Aaron Greenlee <aarongreen...@gmail.com> wrote:
You can see an example of some dev-only stuff on this blog post:http://aarongreenlee.com/share/coldfusion-coldbox-client-source/

I have a snippet from my ColdBox config showing how to register an
interceptor only in a specific environment.

You can read about clearing the items from the cache here:http://wiki.coldbox.org/wiki/CacheBox.cfm(clearAll()) for example.

--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To post to this group, send email to col...@googlegroups.com
To unsubscribe from this group, send email to coldbox-u...@googlegroups.com
For more options, visit this group at http://groups-beta.google.com/group/coldbox
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org

John Whish

unread,
Jan 13, 2011, 9:44:56 AM1/13/11
to col...@googlegroups.com
Yeah you want to do something like this in your interceptor:

 <cffunction name="postProcess" access="public" returntype="void" output="false" hint="This occurs after rendering, usually the last step in an execution. This simulates an on request end interception point."> <cfargument name="event" required="true" type="coldbox.system.web.context.RequestContext" hint="The event object."> <cfargument name="interceptData" required="true" type="struct" hint="interceptData of intercepted info."> <cfscript> var cacheName = arguments.event.getTrimValue("cbox_cacheName","default"); log.debug("postProcess fired, clearing all views"); getColdboxOCM(cacheName).clearAllViews(); </cfscript> </cffunction>

adk

unread,
Jan 13, 2011, 4:06:29 PM1/13/11
to ColdBox Platform
Thanks John... the interceptor works perfectly (that is once I changed
"default" to "template" in your first line of script)

I still think this would make a great boolean setting for the
Coldbox.cfc
Thanks!

On Jan 13, 6:44 am, John Whish <john.wh...@gmail.com> wrote:
> Yeah you want to do something like this in your interceptor:
>
>  <cffunction name="postProcess" access="public" returntype="void"
> output="false" hint="This occurs after rendering, usually the last step in
> an execution. This simulates an on request end interception point.">
> <cfargument name="event" required="true"
> type="coldbox.system.web.context.RequestContext" hint="The event object.">
> <cfargument name="interceptData" required="true" type="struct"
> hint="interceptData of intercepted info."> <cfscript> var cacheName =
> arguments.event.getTrimValue("cbox_cacheName","default");
> log.debug("postProcess fired, clearing all views");
> getColdboxOCM(cacheName).clearAllViews(); </cfscript> </cffunction>
>
> > For Documentation, visithttp://wiki.coldbox.org

John Whish

unread,
Jan 13, 2011, 4:24:59 PM1/13/11
to col...@googlegroups.com
Ack, sorry, I meant "template" :)

Doug Boude

unread,
Jan 13, 2011, 4:57:03 PM1/13/11
to col...@googlegroups.com
To further enhance that interceptor, you could also make it do a check of the environment and conditionally clear the cache.

Curt Gratz

unread,
Jan 13, 2011, 5:03:26 PM1/13/11
to col...@googlegroups.com

One technique I have used is when you set the view caching to set true based on a setting. 

 

event.setView(name=”home”, cache= getSetting(“cacheViews”));

 

Then I can switch the cacheViews flag based on the environment pretty easily.  I try (try being the key word) to do a setting for anything I would want to switch per environment because it is so nice and easy to do.

 

Curt

adk

unread,
Jan 13, 2011, 5:39:25 PM1/13/11
to ColdBox Platform
@Doug - what I did was to only register that interceptor in my
development() function on Colbox.cfc
@Curt - good idea... I will play with that idea too... see whch I like
the best!

On Jan 13, 1:57 pm, Doug Boude <dougbo...@gmail.com> wrote:
> To further enhance that interceptor, you could also make it do a check of
> the environment and conditionally clear the cache.
>
> On Thu, Jan 13, 2011 at 3:06 PM, adk
> <andrew+cold...@leftbower.com<andrew%2Bcold...@leftbower.com>

John Whish

unread,
Jan 14, 2011, 4:17:39 AM1/14/11
to col...@googlegroups.com
The interceptor is only defined in the config for that environment, which is why I didn't add that :)

John Whish

unread,
Jan 14, 2011, 3:52:19 PM1/14/11
to ColdBox Platform
That's a neat idea Curt.

I like to clear the cache using the interceptor instead of stopping
caching completely as I want to know that the caching mechanism is
working. If I set caching off then it would never be used in
development only in production which would worry me. With the
interceptor I can also clear other things from the cache besides
objects in the template cache if I want to.

Also, when I cache views I tend to use the additional settings so I'd
have something like this:

event.setView( name='home', cache=true, cacheTimeout=30,
cacheLastAccessTimeout=10 )

It just seems odd to me to have the cache flag set false but still be
passing the caching arguments, but that's just me being pedantic :)

- John

On Jan 13, 10:03 pm, "Curt Gratz" <gra...@compknowhow.com> wrote:
> One technique I have used is when you set the view caching to set true
> based on a setting.  
>
> event.setView(name="home", cache= getSetting("cacheViews"));
>
> Then I can switch the cacheViews flag based on the environment pretty
> easily.  I try (try being the key word) to do a setting for anything I
> would want to switch per environment because it is so nice and easy to
> do.
>
> Curt
>
> From: col...@googlegroups.com [mailto:col...@googlegroups.com] On
> Behalf Of Doug Boude
> Sent: Thursday, January 13, 2011 3:57 PM
> To: col...@googlegroups.com
> Subject: Re: [coldbox:7694] Re: cached views
>
> To further enhance that interceptor, you could also make it do a check
> of the environment and conditionally clear the cache.
>
> On Thu, Jan 13, 2011 at 3:06 PM, adk <andrew+cold...@leftbower.com
> For more options, visit this group athttp://groups-beta.google.com/group/coldbox
> For News, visithttp://blog.coldbox.org
> For Documentation, visithttp://wiki.coldbox.org
>
> --
> You received this message because you are subscribed to the Google
> Groups "ColdBox Platform" group.
> To post to this group, send email to col...@googlegroups.com
> To unsubscribe from this group, send email to
> coldbox-u...@googlegroups.com
> For more options, visit this group athttp://groups-beta.google.com/group/coldbox
Reply all
Reply to author
Forward
0 new messages