Since we have now created our Cache connection, we can start using it. Let's try it out:
1. Under our
<Railo Install>/webroot/Chapter_5/
folder, let's create a file calledListing5_3.cfm
with the following code:<cfset cachePut('hello','Hello World')> <cfoutput> #cacheGet( 'hello')#</cfoutput>
This code puts the string Hello world into the cache under the key hello. We can then get the item that is present using the cacheGet() function and display it.
This code would output:
Hello World
2. We can expand on this example a little, so you get an idea of the other parameters that we can use with the
cachePut()
function:<cfset cachePut('hello','Hello World',createTimespan(0,0,0,10) ,createTimespan(0,0,0,10),'mycache')> <cfoutput> #cacheGet( 'hello', true, 'myCache')#</cfoutput>
In this example, we call the
cachePut()
method with the following parameters:KeyName:
This is the key name of our item in the...