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!

1 Comment

Add Comment

Your email address will not be published. Required fields are marked *

This blog is meant for Corporate Zen employees to write about a variety of topics. Posts may contain information and views not directly related to Corporate Zen!