Blog

Curt Gratz

February 01, 2013

Spread the word


Share your thoughts

 


ColdBox-CacheBack

A cool annotation based Caching Aspect for WireBox/ColdBox that provides caching without blocking requests during refresh

This interceptor will inspect objects for the 'cacheBack' annotation and if found, it will wrap it in a thread creating cache. This allows the function to be cached without waiting for it to refresh. Inspiration from God and from this library. http://django-cacheback.readthedocs.org/en/latest/

This aspect is a self binding
aspect for WireBox that registers itself using the annotations below
You can control the refresh rate for your cache and the timeout in a number of ways
    1) You can add an annotation to your method called refreshRate and timeout
        ie function myFunction() cacheback refreshRate=120 timeout=240 {}
        This will set cache to refresh every 2 mins and timeout every 4 mins.
    2) You can add a settings to your coldbox config called cacheBack.  The setting will be a structure with
       keys of refreshRate and timeout
        cacheBack = {refreshRate=60,timeout=120}
        This will set cache to refresh every 60 secs and timeout every 120 secs.
    3) You can use our default timeouts which are a refresh rate 18 mins and a timeout of 20 mins
All refresh rates and timeouts are in seconds

To activate this aspect you will need to map it in your WireBox binder.  This can be done like below
mapAspect("cacheBack").to("model.aspects.cacheBack");
Then all you need to do is add the annotation cachback to your methods
myFunction() cacheback refreshRate=120 timeout=240 {}

Keep in mind like all things caching, testing and tuning is very important. This can be used in very specific scenarios when you want to keep cache refreshing, but don't want users to wait for the refresh.

The GitHub repo is available at https://github.com/gratzc/ColdBox-CacheBack

You can also download from our ForgeBox http://www.coldbox.org/forgebox/view/CacheBack

Hope you enjoy.

 

Add Your Comment

(1)

Feb 08, 2013 17:09:20 UTC

by Ken

Coolness!

Recent Entries

ColdBox 7.2.0 Released

ColdBox 7.2.0 Released

ColdBox, a widely used development platform for ColdFusion (CFML), has unveiled version 7.2. Packed with compelling new features, bug fixes, and enhancements, this release is designed to empower developers by boosting productivity, refining scheduled task capabilities, and enhancing the overall reliability and efficiency of application development. This article will delve into the key highlights of ColdBox 7.2 and elucidate how these advancements can positively impact developers in their daily coding endeavors.

Luis Majano
Luis Majano
November 20, 2023
Into the Box 2023 Series on CFCast

Into the Box 2023 Series on CFCast

Excitement is in the air as we unleash the highly anticipated ITB 2023 series exclusively for our valued CFCast subscribers – and the best part? It's FREE for CFCast members! Now is the perfect time if you haven't joined the CFCast community yet. Plus, we've got an incredible End-of-Year deal that's too good to miss

Maria Jose Herrera
Maria Jose Herrera
November 20, 2023
Ortus Deals are Finally Here!

Ortus Deals are Finally Here!

The much-anticipated Ortus End-of-the-Year Sale has arrived, and it's time to elevate your development experience! Whether you're a seasoned developer, a tech enthusiast, or someone on the lookout for top-notch projects, Ortus has something special in store for you. Brace yourself for incredible discounts across a wide array of products and services, including Ortus annual events, books, cutting-edge services, and more.

Maria Jose Herrera
Maria Jose Herrera
November 15, 2023