memcached client CFC for BlueDragon.NET
We were recently asked by a customer whether BlueDragon.NET could support memcached, a "high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load." Though BlueDragon.NET already supports query caching, our customer's goal is to implement a cache that can be shared across multiple servers in a cluster and that can store data types other than just query results.
In response to their request we created the Memcached client CFC for BlueDragon.NET, which is based on the .NET memcached client library.
Using the Memcached client CFC is fairly straight forward:
- Copy the Commons.dll, ICSharpCode.SharpZipLib.dll, log4net.dll, and Memcached.ClientLibrary.dll libraries into the "bin" directory of your web site or web application.
- Create an instance of the Memcached CFC, initializing it with an array of memcached server addresses and other optional parameters.
- Use the Memcached CFC methods to get and set named variables.
<cfset ArrayAppend( servers, "192.168.200.117:11211" )>
<cfset application.memcached = createObject( "component", "Memcached" ).init( servers )>
Now simply use the Set, Get, and other Memcached CFC methods to store and retrieve variables from the memcached servers. For example, here's how you might implement caching of a query variable with a two-hour expiration:
<cfif employees eq null>
<cfquery datasource="ows" name="employees">
SELECT * FROM Employees
</cfquery>
<cfset application.memcached.Set( "employees", employees, DateAdd( "h", 2, Now() ) )>
</cfif>
Some additional information for CFML programmers who are not using BlueDragon.NET:
- There are two memcached client CFCs that have been written for ColdFusion: cfmemcached and Memcached Client. I don't know if these work on the Java editions of BlueDragon, but I'm sure we could get them to work if you're interested (let me know).
- Support for memcached has been integrated into OpenBD 1.0, which was just recently released. If this turns out to be a popular feature we'll roll it out in a future release of the commercial BlueDragon editions.


There are no comments for this entry.
[Add Comment] [Subscribe to Comments]