ColdFusion in Context: Quick Reset
Suppose you've been doing database work or changing memory variables as part of your application, and now the database is hung or your memory variables are in an uncertain state. This short tip will give you ways to quickly reset your environment so you can proceed with coding and troubleshooting.
Database Reset
One way to regain control of a hung datasource is to send it a query that will cause a database error. Here is such a query. It doesn't look like much, but it can save you a half-hour or so waiting for a connection to drop naturally. I call it bumpdb.cfm.
<cfquery name="bump" datasource="context">
select
</cfquery>
Memory Reset
Suppose your code writes to a memory variable and you want to remove the variable so you can start fresh. Here's an example that will do that. I called it noticeaq.cfm; because, I wanted to quit working with an application variable named "notice".
It doesn't clear the entire structure. It deletes a specific element from the structure. Remember if you're emulating this approach that application and session variables are contained in structures but that client variables are not. (They "fake it".)
<cfapplication name="Notice" sessionmanagement="no">
<cflock name="crasher" timeout="30">
<cfset dummy=structDelete(application,"Notice")>
</cflock>
I hope these hints help you when you need it most. Happy Hunting! =Marty=
[To avoid disrupting the site, these tips are not actually demonstrated here.]