ColdFusion Database Pool Master/Slave(s)

Last week when I looked at databases pools I got a few suggestions re master/slaves databases. In this configuration you set up a single database (called the master) and have it replicate to one or more other databases (called the slaves).


ColdFusion Database Pools and Resource Counting

With a discussion with Sammy he suggested that my ColdFusion database pool DSN component could be extended to select the current datasource with the least no of connections rather than just randomly picking one.

Here's the modified code.


ColdFusion Internationalisation

Using ColdFusion it's fairly straight forward to make web pages appear in more than one language.

First off you need to detect what language you want the page to be in, next you load the strings you want to display from a resource file and lastly display the page in the required language.


ColdFusion RAID databases (or database pools)

You've tuned your databases queries, added all of the indexes you can think of and cached all of the queries you can but your database still isn't giving you the performance you need.

So it's time to split up your database into several databases and move each of these new databases off onto separate database servers. Or perhaps a RAID database is the solution to your performance issues.


ColdFusion Singletons Revisited

My last article on singletons got a few comments on blogs and in email including how it could be improved (thanks Michael) and a few questions. I also omitted the code showing how the singletons were created and called (now added).

So here's the new improved code!


ColdFusion Singletons

Singletons are perhaps one of the most simple Design Patterns. For those who don't know sigletons are a class that can only have one instance. They can be thought of as a glorified global variable - but are a lot more useful.

Most ColdFusion classes, or rather instances of CF components, can be turned in a singleton by placing the following code in your Application.cfm:

view plain print about
1<cfif not structkeyexists(application,<instance name>)>
2        <cfset application.<instance name> = createobject("component",<path to component>)>
3    </cfif>

or OnApplicationStart method of your Application.cfc:

view plain print about
1<cfset application.<instance name> = createobject("component",<path to component>)>