The Ortus BlogBox

"Ortus: A rise, beginning, coming into being, born, the origin!"

 

 

Category Filtering: 'alliance'

 

Introducing CacheBack - A caching WireBox aspect

Curt Gratz
Feb 01, 2013

 

 


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.

 

Alliance, CacheBox, ColdBox, Interceptors, WireBox 1

Mock It Baby Slides and Code

Curt Gratz
May 21, 2012

 

Thanks to all who came out to my presentation at this years CF.Objective().  It was my first year speaking and it was an honor to have you and I would like to say thank you to the conference orginazators for the opportunity and for putting together such a great conference.  

The slides and code for my Mock It Baby! presentation our available on github

Mock It Baby

This years CF.Objective() was another great conference with deep content, good friends, and good food.  I enjoyed meeting so many new friends, catching up with old friends, and generally hanging out.

Alliance, ColdBox, Events, Media, MockBox, Presentations 0

HQL Query to Criteria Query Example

Curt Gratz
Feb 08, 2012

 

I have been using criteria queries in favor of HQL queries quite a bit latley, so I thought  I would do a quick post of what a query would look like in HQL and then the same query written as a criteria query.

Some of the reasons I like to use criteria queries are

  • Readablity
  • No building up query strings and concatenating them to build a complex query
  • Powerful Object Oriented API

You can learn more about using criteria queries on our wiki at http://wiki.coldbox.org/wiki/Extras:CriteriaBuilder.cfm

OK, on to the example.

First, the HQL version of the query

HQL Query


var qs = "";
qs = qs & "select r from Response as r INNER JOIN Activity as a";
qs = qs & " where r.id=:id and a.uid=:uid";
qs = qs & " order by a.pagenum asc";
var params = {id=rc.id,uid=userID};
var results = RService.executeQuery(query=qs,params=params,offset=0,max=25,asQuery=false);
qs = "count(r.id) from Response as r INNER JOIN Activity as a";
qs = qs & " where r.id=:id and a.uid=:uid";
var count = RService.executeQuery(query=qs,params=params);

 

So, you can see, there is a lot of concatenating strings, and then we need another version of the query to get the count, so now lets look at how we can do that same thing with a criteria query

Criteria Query

var c = RService.newCriteria();
c.eq('id',rc.id)
   .createAlias('Activity','a')
   .and(c.restrictions.eq('a.uid',userID))
   .order('a.activity','asc');
var count = c.count();
var results = c.list(max=25,offset=0);

 

What is nice about this is, not only is it more concise, it will make only one trip to the database to return both the count and the list. I encourage you to go to http://wiki.coldbox.org/wiki/Extras:CriteriaBuilder.cfm and check out what you can do with criteria queries and how you can incorporate them into your ORM enabled applications to make finding entities even easier.

Alliance, ColdBox, Community, Tips & Tricks, Tutorials, Walkthroughs 0

ColdBox Connection: RC What??

Curt Gratz
Oct 14, 2011

 

Here is the presentation in PDF format and also the source code from the ColdBox Connection yesterday on RC What? The basics differences between the Request Context and Request Collection as well as uses of the request context decorator.

Alliance, ColdBox, ColdBox Connection, Community, Training, Tutorials, Walkthroughs 0

ColdBox Connection: The Developer ToolBox

Curt Gratz
Jul 07, 2011

 

Todays ColdBox Connection topic was "The Developer ToolBox".  We discussed the various tools Luis and the team have made available to you the developer to make your life easier.  

You can access the recording at http://experts.adobeconnect.com/p1xv6sqjzl1

Alliance, CFBuilder, CodeDepot, ColdBox, Community, ForgeBox, Presentations, Releases, Sample Apps, Tips & Tricks, Training, Tutorials, Walkthroughs 0

ColdBox Quick Docs Released

Curt Gratz
Jul 07, 2011

 

The ColdBox Quick Docs are released for your use.  They allow you to quickly search any of the ColdBox Platform APIs.  

http://apidocs.coldbox.org/

We have also released the module used to run the quick docs to ForgeBox

http://www.coldbox.org/forgebox/view/Quick-Docs

 DESCRIPTION

 

Basic Requirements: 

  • Coldbox 3.1.0
  • Autowire Interceptor enabled.
  • SES Interceptor enabled.

 

 INSTALLATION INSTRUCTIONS

Grab the Module and place it in the Modules Directory.

 

 

Alliance, CFBuilder, CodeDepot, ColdBox, Community, ForgeBox, Media, News, Releases, Tips & Tricks, Training 0

WireBox Binder and Configuration Introduction

Curt Gratz
Mar 15, 2011

 

This video shows the basics of setting up a "Binder" with WireBox and how to setup mappings and alias using the WireBox DSL for super simple dependency injection that is easy to read.

WireBox Binder and Configuration Introduction... from Curt Gratz on Vimeo.

Again, this is not even scratching the surface of what the binder in WireBox can do. Below are some other simple changes you could make to the binder or ways you could do injection

So this line

.initArg(name="daoPath",dsl="id:daoPath"); Could change to .initArg(name="",ref="daoPath") //refpoints to an id directly

as one possible alternative, so if we wanted, we could remove the .initArg and do it via annotations

function init(required daoPath inject) or function init(required daoPath inject="id") or function init(required daoPath inject="id:daoPath")

So, as you can see, you can do your injections a variety of ways. Now, go, read the docs, and install WireBox and get wiring your model up the easy way.

Alliance, ColdBox, Presentations, Tips & Tricks, Training, Tutorials, Walkthroughs, WireBox 0

WireBox Installation and Introduction Screencast

Curt Gratz
Mar 14, 2011

 

This video shows how to download and install the WireBox framework and offers super simple example of dependency injection using WireBox without any configuration or messy XML.

 

WireBox Installation and Introduction... from Curt Gratz on Vimeo.

Again, this is not even scratching the surface of what WireBox can do, but I wanted to get you started and thinking. More screencasts will be following to help you go deeper into how WireBox can help you in your development.

Now, go, read the docs, and install WireBox and get wiring your model up the easy way.

Alliance, ColdBox, Media, Presentations, Tips & Tricks, Training, Tutorials, Walkthroughs, WireBox 0

Don't Forget persistent="false" When Autowiring Entities

Curt Gratz
Jan 21, 2011

 

I ran into a strange error yesterday that I couldn't seem to find out what was happening.

I was getting coldfusion.runtime.TemplateProxy cannot be cast to java.lang.String when trying to save an entity using ColdFusion ORM.  

Google was turning up nothing, so I started systematically removing lines of code.  It started working when I removed the line that did an entityLoad on a different object.  What was weird was I was just using that object to get a bit of data and not even for the object I was saving that caused everything to go boom, and if I removed the save, everything worked fine.  Then I remembered that the Hibernate session is affected so I took a deeper look at the entity that a loaded.  Sure enough, I was autowiring a property and didn't have persistent="false" on that property, causing it to throw the "coldfusion.runtime.TemplateProxy cannot be cast to java.lang.String" error.

Changing it from something like this

property name="shippingOriginationZip" inject="coldbox:setting:shippingOriginationZip";

to this

property name="shippingOriginationZip" inject="coldbox:setting:shippingOriginationZip" persistent="false";

fixed it all up.  Of course, like all coding solutions happen, this was in the middle of the night when I was no longer working on the code that this came to me.

So remember folks, if you have a property in an persistent CFC that is not persistent, be sure to say so!

Alliance, Bugs, ColdBox, Tips & Tricks, WireBox 0

ColdBox at the OpenCF Summit

Curt Gratz
Jan 19, 2011

 

ColdBox will be at OpenCF Summit. Don't know what the OpenCF Summit is? It is "a community gathering focused exclusively on advancing free and open source software in the CFML community."

I will be hosting a offical ColdBox Unconference. I am very excited to meet with other developers(ie YOU) and have a conversation about advancing ColdBox and sharing some of the different ways we can use the robust framework in our development. I am also excited about learning more about some of the different Open Source ColdFusion projects and ways we as a community can advance those projects. What a great concept for a conference.

If you are wondering why you should care open this "open source" stuff, Bob Silverberg recently posted Why Contribute to Open Source Projects?

If you are wondering why you should go to the OpenCF Summit, check out Jamie Krug's post Go To OpenCF Summit!

If you still aren't convinced to go, the great news is, the price was just dropped to $30. So for the price of a dinner you get

  • A 3 day professional conference
  • A great lineup of speakers
  • The chance to participate in a community "hackfest"
  • The opportunity to network within the greatest development community on the planet

If you have any ideas for things you would like to discuss at the ColdBox Unconference, leave me a comment and we will do our best to cover your idea in some fashion, or just come to the event with your creative juices flowing.

See you at the OpenCF Summit.

Alliance, ColdBox, Community, Conferences, Events, News, Training, Tutorials 0