I've never used cfcache before, I'm looking to loa...
# cfml-general
j
I've never used cfcache before, I'm looking to load a small list of whitelist IP addresses from a file into a a memory cache to reduce I/O for page requests. Questions: 1. ACF documentation isn't too clear - but it seems the cache (serverCache) is server wide, not per application or session, correct? 2. If so, I assume I should give an ID that is unique to avoid conflicts - correct? 3. To check for updates from the IP whitelist file, I assume I should just set the timeSpan with a value of like 5 minutes, so then if the cfcache for the ID isn't found, then I know to reload the whitelist from the file - is this correct? Any other advise?
e
cfcache action="put" name="#MycacheName#" value="#MywhitelistedIPs#" duration="#MycacheDuration#" , then define logic aroud your cache bring full or empty.
a
I hate that lazy tags-to-script syntax. I'm recommend writing code using
cacheGet
and
cachePut
. The cache is per application. Code typically looks something like:
Copy code
function get() {
  var cacheKey = "A_UNIQUE_NAME";
  var resut = cacheGet( cacheKey );
  if ( !isNull( result ) ) {
    return result;
  }
  // you may want to add a lock here before getting data...
  var data = {...get data here...}
  cachePut( cacheKey, data, createTimeSpan( 0, 0, 0, 5 ) );
  return data;
}
j
Thanks all
👍 1