Skip to Content

ColdFusion CacheGet Variable Does Not Exist Gotcha

I am using Railo and EHCache to cache an array of 300,000 items from a database that need to be updated every 30 minutes.  So, naturally, I use the CacheGet() and CachePut() functions.

Here’s my code, really simple: <cfset cachedURLList = cacheGet(“URLList”)>

Every few minutes I would get an error report from our server….”variable [CACHEDURLLIST] doesn’t exist”.  I realized that CacheGet() must return the object by reference.  I am only caching URLList for 5 minutes.  I must have been making a request at the 4:30 minute mark, the requests each last 90 seconds or so, and midway through the request at the 5:00 minute mark my object is getting removed from memory by EHCache.

I solved the issue by using the Duplicate() function, like this: <cfset cachedURLList = duplicate(cacheGet(“URLList”))>
I hope this helps someone out!

Get in touch so we can start your
next web project!

Let us know what you’re looking for. We strive to respond in 48 hours, but, every now and then, life gets in the way, so be patient if there’s a delay.


    Back to top