Function Cache (a-la cachedWithin) seems to ignore the state of an object. It seems that the key is based on the Component’s path and arguments, resulting in a “static” behavior, where all instances of the Component share the same cache key.
Consider the following:
/** FunctionCacheTest.cfc */
component {
function init(uri){
this.uri = arguments.uri;
}
function test() cachedWithin=createTimespan(0,0,1,0){
http url=this.uri result="local.httpRes";
return httpRes;
}
}
And the following pseudo-code that calls the test() method on two different instances:
test1 = new FunctionCacheTest("https://www.google.com/");
test2 = new FunctionCacheTest("http://lucee.org/");
assertFalse(test1.test().fileContent == test2.test().fileContent);
I expected each instance to keep its own “cache”, but that’s not what happens. test2.test()
returns the result from google.com
I opened a ticket for this as a bug, but TBH I’m not sure if it is a bug or if that is the expected behavior, or how ACF behaves on that (perhaps someone knows or has an ACF installation handy to test):
https://luceeserver.atlassian.net/browse/LDEV-1348