In my last post I wrote about using ZIP and FTP as resource locations.
Today, I want to focus on why you might want to use RAM as a resource. Imagine the situation, for some crazy reason, you happen to have some code in your database, that you want to actually run. Its in fact just a text string, but you want to run this code. Let's say it is a code example in a blog post or something. How would you get this code to run?
A good way to do this is to setup a ram resource, this is fairly easy, again in a mapping you can create:
Virtual: ramdisk
Resource: ram:///
Now all we have to do in our code is:
<cffile action="write" file="/ramdisk/test.cfm" output="<cfdump eval=server>">
<cfinclude template="/ramdisk/test.cfm">
And what you should see is that the string "<cfdump eval=server>" has been executed and rendered correctly!
Very useful if you want to cache and execute content, or just for temporary files!
Tweet
comments powered by Disqus