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

Into the Box 2024 Last Early Bird Days!

Into the Box 2024 Last Early Bird Days!

Time is ticking, with less than 60 days remaining until the excitement of Into the Box 2024 unfolds! Don't let this golden opportunity slip away; our exclusive Early Bird Pricing is here for a limited time only, available until March 31st. Why wait? Secure your seat now and take advantage of this steal!

Maria Jose Herrera
Maria Jose Herrera
March 20, 2024
Ortus February Newsletter 2024

Ortus February Newsletter 2024

Welcome to Ortus Solutions’ monthly roundup, where we're thrilled to showcase cutting-edge advancements, product updates, and exciting events! Join us as we delve into the latest innovations shaping the future of technology.

Maria Jose Herrera
Maria Jose Herrera
March 06, 2024
Unveiling the Future of CFML Development - 3rd Round of Sessions

Unveiling the Future of CFML Development - 3rd Round of Sessions

Welcome back to our journey into the future of CFML development! As excitement continues to build for Into the Box 2024, we're thrilled to bring you the latest updates on what promises to be a transformative event. Continuing our blog post series, let's delve deeper into the third wave of session releases and discover the key surprises awaiting attendees. Learn More

Maria Jose Herrera
Maria Jose Herrera
March 01, 2024