How do I clear the coldfusion query cache without restarting the server?

Jake Feasel picture Jake Feasel · Dec 13, 2011 · Viewed 7.2k times · Source

I have several queries that I cache using the cachedwithin="#CreateTimespan(...)#" attribute of the cfquery tag. There are times when I need to clear the cache (or just re-execute the query to get a new cached copy). Historically, I've done one of two things to accomplish this -

  1. Restart the coldfusion service.
  2. Slightly alter the query in the code, say by adding or deleting whitespace.

Neither of these options are very good, especially when in production. I'm not asking for how I might expire the cache programmatically (although, that would be nice!), but more simply - how can I clear the cached queries on the server without having to resort to one of those two above methods? I'd be happy to hear about methods that work either server-wide, or application-wide, or even how to expire a specific cached query. Thanks!

Answer

Barry Jordan picture Barry Jordan · Dec 13, 2011

You can use the following:

<cfobjectcache 
    action = "clear" />

See cfdocs for a full explanation.