Nov
30

For my final post in this 14 day caching series I want to look at setting the server cache properties at runtime. I showed how to retrieve the cache settings in yesterday's post using the cacheGetProperties() function. To set the cache properties for either the template or object cache you use the cacheSetProperties() function. Consider the following code.

Continue Reading

Nov
29

We're in the home stretch now. Just two more days until this ColdFusion 9 caching series is finished. Today we're going to look at code that retrieves the server-wide Ehcache settings. But before we examine the code we need to first know where the cache settings are and what they mean.

Continue Reading

Nov
28

Yesterday I showed examples loading up template and object cache with sample data and viewing the sample data with a series of <cfdump> statements. Today, I want to take this concept a bit further and show you how to remove all items stored in both template and object cache.

Continue Reading

Nov
27

For today's post-holiday caching entry I want to look at code that shows how to report information (metadata) on all items stored in cache. This includes both template cache and object cache. And since it's a holiday and I have some turkey and dressing to get to, let's jump right in. Here's the example code:

Continue Reading

Nov
26

First off, Happy Thanksgiving to my fellow Americans!! I hope each of you have an awesome day; I know I will. Today's caching example will be a little shorter than my previous examples but hey, it's a holiday.

ColdFusion 9 doesn't have built in session-based caching when it comes to the template or object cache. But, we've had shared scopes such as Server, Application, and Session for as long as I can remember. Using shared scopes in CF applications are pretty much a de facto standard as they're central to building applications that maintain state and store data across minutes, hours, days, or more. Now, consider how Ehcache in ColdFusion 9 works. By default there's one cache region defined in the ehcache.xml file. Within this region of cache exist the template and object cache. Each Application on your ColdFusion server will have a shared template and object cache. This is nice as it allows you to build cache keys inside of one application that won't collide with cache keys in another. But sometimes you want even more granular storage of cached data than this. You might want to associate a cached item with a specific user and have the code work with any number of users visiting your site. A shopping cart is a common example of this type of behavior.

Continue Reading

Nov
25

Dependent Caching is a new feature in ColdFusion 9 that I immediately thought would be really useful. But when it came time to create an actual example for my BFusion talk back in October I was at a loss. I talked with my team at Dealerskins hoping they'd have some good ideas and while we all came up with a few none were fantastic. As MAX 2009 approached I continued to struggle with concepts I thought were doable but just weren't "real world" enough. I wound up creating an example based on a fictional order processing system. This still isn't good enough in my mind, but it works and should be fine for an example in a blog post. With that said, Rob has come up with a better example so I encourage folks to read through his post on this topic as well. But don't leave just yet! Read through this post first.

Continue Reading

Nov
24

I've done well to get each of these caching blog posts written the night before they were "due" and have them scheduled for an 8:00am release. Not today. Last night I was incredibly tired and decided to wait until today to get this one out. Here it is after 9:00pm and I'm just now getting to it. Oh well, fasten your seatbelt folks because here we go!

Continue Reading

Nov
23

Several years ago I read Understanding the Psychology of Programming by Bryan Dollery. The article was written in 2003 but you'd never know it unless you saw the date. It talks about how programming is a creative activity and how the environment of a programmer plays a large role in their creativity. I've referred to the article dozens of times over the last 6 years when conversing with other technical managers and today I want to share it with you. If you're a programmer or you are directly or indirectly responsible for the management of programmers you must read this article.

Understanding the Psychology of Programming

Contrary to popular belief, programmers more frequently resemble artists than scientists. If you want to maximize the creative potential on your development team, you've got to start thinking about the psychology of the programmer and be willing to back it up with management policy.

Read it here.

Nov
23

Building on yesterday's example that used cacheGet() and cachePut(), today we'll look at removing items from cache. If you haven't read yesterday's post yet I encourage you to as it includes definitions for ColdFusion 9 caching terminology mentioned in this post.

Right off the bat I need to mention how I wish there was verb consistency between the <cfcache> tag and the cacheRemove() function. When you want to remove an item from cache using the <cfcache> tag, you use the action "flush." But when you want to remove an item from cache with a function you use cacheRemove(). If I had to pick which verb was more indicative of the action taken it'd be flush.

Continue Reading

Nov
22

Today's caching example moves us away from the template cache and into the object cache. I defined these two types of caches on day three of this series but let's revisit the definitions. The template cache in ColdFusion 9 refers to a specific area of cache where page fragments and full page cache items are stored. The object cache refers to anything cached except pages including strings, arrays, ColdFusion components, queries, XML, or the like.

Let's look at a simple example that illustrates the use of three new functions in ColdFusion 9: cachePut(), cacheGet(), and cacheGetMetadata().

Continue Reading

Nov
22

Reading through the CFBloggers feed the other day I noticed the first round of CFUnited 2010 speakers had been announced. I clicked through to the CFUnited blog and noticed my ColdFusion 9 caching submission had been accepted. While it seems like CFUnited 2010 is 9.4605284 × 10^15 meters in the future (points to the first person who knows how long this is) I'm looking forward to the opportunity to attend again. I really enjoyed this years conference which was the first time I had been back to CFUnited since 2006 as well as my first time speaking at the conference. The sessions were great, the food, company, and beer were fantastic and I even found time to play a round of golf with Scott Stroz, Dan Wilson, and Jason Delmore. If CFUnited 2010 is anything like 2009 it will be a conference not to miss.

Check out the pricing schedule to see when certain discounts end, and register now.

Nov
21

Before I jump into today's ColdFusion 9 caching content I want to bring up yesterday's post about flushing pages from cache. Rob Brooks-Bilson, long-time ColdFusion community contributor and all around great guy mentioned I had neglected a critical part of my post. I had left off the useQueryString attribute when caching the page which would cause ColdFusion to cache the template once regardless of the URL parameters passed in. I set out to "fix" my post and jumped into a ball of confusion that in the end chewed up hours of my day. Long story short, if you read yesterday's post you need to read it again. I wound up rewriting most of the post in order to explain what I feel is a bug in ColdFusion 9.0.

Today, I want to talk about the difference between a cache timespan and idletime and explain how they work together. Here's the sample code for today.

Continue Reading

Nov
20

Say it with me: SlideSix, SlideSix, SlideSix. The other day I was talking with another frequent presenter who was mentioning sharing his slides on a popular online site that rhymes with "wide snare." I asked him why he used the particular site and he really had no idea. I asked him if he had heard of SlideSix and he said no.

Continue Reading

Nov
20

Thus far I've written about caching an entire Web page, caching part of a Web page, and viewing page cache metadata. Today I want to focus on flushing pages and page fragments from the template cache. This task is easily accomplished using the <cfcache> tag with the action attribute set to "flush."

Continue Reading

Nov
19

Today's caching example builds on yesterday's with one key difference, the last line. But before I explain that line, this is the perfect opportunity to talk about two different types of caches in ColdFusion 9: template cache and object cache. The word "template" is relatively specific to ColdFusion. I haven't heard any other programming language refer to code files as templates. Following this nomenclature, the template cache in ColdFusion 9 refers to a specific area of cache where page fragments and full page cache items are stored. The second cache is referred to as the object cache. Virtually anything can be stored in object cache such as strings, arrays, ColdFusion components, queries, XML, or the like. In later posts I'll dive much deeper in to the object cache as it's the most flexible way to utilize Ehcache in ColdFusion 9.

Continue Reading