This is just a minor note, but I found out the other day that the structure returned from ColdFusion's GetMetaData() method is not unique to the instance on which it was called. Rather, the structure seems to be shared among all instances of a given class (component definition). This means that if you update the Meta Data for a given CFC instance, it updates the Meta Data for all instances of the same time. And what's more, this has nothing to do with the persistence of any of the objects in question. Even if you do this on a page where the object is not cached, newly created instances of the given component on subsequent page requests will still have the updated meta data. And, on top of that, the Meta Data does not seem to be related to the application timeout. I guess the meta data for a given class gets stored in the trusted cache or something?
To see this in action, take a look at the following code:
<!--- Create a test component. ---> <cfset firstTest = createObject( "component", "Test" ) /> <!--- Create another test component. ---> <cfset secondTest = createObject( "component", "Test" ) /> <!--- Now that we have two instances of our test component, update the meta data for just one of them. ---> <cfset getMetaData( firstTest ).forBlog = true /> <!--- Output the meta data for both components to see how they were updated. ---> <cfdump var="#getMetaData( firstTest )#" label="First Test Object" show="name,forblog" /> <br /> <cfdump var="#getMetaData( secondTest )#" label="Second Test Object" show="name,forblog" />
The actual component here is empty, which is irrelevant. What's important to notice is that I am creating two separate instances of the component, but only changing the meta data on one of those instances. When they are then both CFDump'd out to the page, we get the following output:
As you can see, the meta data for both of the ColdFusion component instances now contains the "forBlog" key even though only one of the instance' meta data was directly updated.
This is a really minor piece of information; but, I recently started playing around with meta data and this minor point became an important caveat to understand. Perhaps more on this later.
Want to use code from this post? Check out the license.