Viewers: in countries Watching now:
In ColdFusion 9 New Features, author and developer Dan Short has gathered together the important updates and improvements in this dynamic web application. Dan showcases the new ColdFusion Builder application throughout the course, using it to work through the new language and CFScript enhancements in this release. He shows how to use the new Server Manager to compare servers and create server groups, as well as monitor server health through notifications. He also explains the new integration with Office applications, building Excel, Word, and even PowerPoint files on the fly from ColdFusion. Finally, he covers the important new Object Relational Mapping feature and how to use the built-in Flash Player. Exercise files accompany this course.
When dealing with cached content, you can't always rely on timeout values for managing the cache. There are times when you need to forcibly update or remove something and you need it to happen right away. In this video I am going to show you how to figure out what you have in your cache and show you how to add and remove items at any time. So to get started we are going to use the same file we used in the caching page fragments video. And the first time I am going to show you how to do is to make it so that this cached page fragment is available to other pages, so we can get it into the cache properly to manage it.
So currently I just have everything with a cfcache tag wrapped around it. Generally if you are going to be caching data that's used in multiple places, you'll have a single file that perhaps runs on a schedule and we re-caches the data into the cache. So to change the way this works, we are going to take off the cfcache tag and instead wrap all of this into a cfsavecontent and put all of the content into a new variable.
So now I have all of this content in a variable called CachedPagecontent. So down here at the bottom, I am going to get rid of this closing cfcache tag, and instead say cfset Cache Put. I am going to specify an ID for this content and then the actual content that I want to be cached. So we are going to call this Artistlist and we are going to put our CachedPagecontent in there. So I am going to go to my browser and we still have our pagefragment cfm open.
I am going to reload that page and I don't have any output because I am not outputting anything to the screen. Now that I have some new item with an ID in my cache, let's open cachemanagement.cfm and play around a little bit. The first thing we are going to do is dump out all of the IDs for our data in the cache. I use the CacheGetAllIDs() function. If I preview that file, you'll see that I only have one item in my cache called ARTISTLIST. Now that doesn't tell me a whole lot, but I can get some information about what's in there.
For example, I can also dump out cacheGetMetadata and I can tell it dump out all the metadata on Artistlist. I'll reload that page and we can see that particular item hasn't been hit at all and hasn't been missed either obviously. But I can see when it was created, how long it will stay idle before it gets removed from the cache and when it will expire. So these are default values. You can provide an idle timeout and regular timeout directly in the cacheput() function.
We can also see the size of the data inside that cache. So what if I want to get that data out? Let's go back to the source code here and I want to output what is in the ArtistList cache item. So I can do ArtistList, I'll reload my page and we can see all of the data that was cached into the ArtistList item. Now if I reload this page again, here you see that the hitcount is going up and my lasthit is also going up.
So I can see how many times data that's in the cache actually gets hit. Now let's say I want to remove that data from the cache. I can use cfset CashRemove, say ArtistList and now that data has been removed from the cache. I'll reload the page and we can see that my array and struct are both empty. If I go back over to pagefragments and load it, go back over to cachemanagement and reload it, and you can see that data gets added back to the cache and because I still have the CacheRemove, if I refresh it's dropped out of the cache again.
Now let's do that one more time. I want you to see how the counts change. So now I have reloaded it back into the cache. I am going to go over to cachemanagement and take out our CacheRemove. Now if I reload this page, take a look at the hitcount versus the misscount versus the regular hitcount. So cash hitcount means that this particular ID has been hit 10 times. It's been missed 5, I loaded a page 5 times where that cache item did not exist, and the current item in the cache hasn't been hit at all.
If I reload the page, we can see that the hitcounts go up and the misscount stays the same. And those were all the biggies for managing cache inside ColdFusion 9. You now know how to put a new item in the cache, get it back out and take a look at all of the IDs that are in your cache so that you can go find out more about them.
There are currently no FAQs about ColdFusion 9 New Features.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.