Whatever message this page gives is out now! Go check it out!
The cfcache tag caching mechanism considers that each URL is a separate page. Therefore, http://www.mySite.com/view.cfm?id=1 and http://www.mySite.com/view.cfm?id=2 result in two separate cached pages. Because ColdFusion caches a separate page for each unique set of URL parameters, the caching mechanism accommodates pages for which different parameters result in different output. |
<cfcache timespan="#CreateTimespan(1, 0, 0, 0)#" directory="e:/temp/page_cache"><cfcache action="flush" directory="e:/temp/page_cache/monthly" expirURL="HR*"><cf output>
W elcome to our home page.<br>
The time is #TimeFormat(Now())#.<br>
Your lucky number is: #RandRa nge(1,1000)#<br>
<hr>
</cfoutput>
<!--- If the flag is false, query the DB, and save an image of
the results output to a variable. ---> <cfcache action="optimal" timespan="#createtimespan(0,1,0,0)#" idletime="#createtimespan(0,0,30,0)#"><!--- Perform database query. ---><cfquery dataSource="cfartgallery" name="specialQuery"> SELECT * from art
</cfquery>
<!--- Calculate sale price and display the results. --->
<h2>Check out the following specials</h2>
<table>
<cfoutput query="specialQuery">
<tr>
<td>#artid#</td>
<td>#Description#</td>
<td>#price#</td>
</tr>
</cfoutput>
</table></cfcache><hr><p>Thank you for visiting us!</p>this.cache.configfile = "c:/cachesettings/ehcache.xml";this.cache.configfile = "ehcache.xml";<cfscript>
this.name = "appSpecificCacheTest";
this.cache.configfile = "ehcache.xml";
this.applicationTimeout = createtimespan(0,0,0,5);
function onApplicationStart(){
writelog("In onApplicationStart()");
}
function onApplicationEnd(){
writelog("In onApplicationEnd()");
}
</cfscript>
</cfcomponent><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>cfhttp</title>
</head>
<!--- End of header --->
<body>
<!--- remove object from Application Specific cache --->
<cfif ArrayLen(cacheGetAllIds()) gt 0>
<cfset cacheRemove(ArrayToList(cacheGetAllIds()))>
</cfif>
<cfset obj1 = structNew()>
<cfset obj1.name = "xyz">
<cfoutput>Starting to write to cache..</cfoutput>
<cfset cachePut("obj1",obj1)>
<br/>
<cfoutput>Done!!</cfoutput>
<cfoutput>Trying to fetch cached item...</cfoutput>
<cfset obj = cacheGet("obj1")>
<br/>
<cfdump var="#obj#">
<cfscript>
sleep(15000);
</cfscript>
<cfoutput>Trying to fetch cached item after 15 seconds...<br/></cfoutput>
<cfset obj = cacheGet("obj1")>
<cfdump var="#obj#">
</body>
</html><ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd">
<diskStore path="java.io.tmpdir"/>
<cacheManagerEventListenerFactory class="" properties=""/>
<defaultCache
maxElementsInMemory="5"
eternal="false"
timeToIdleSeconds="30"
timeToLiveSeconds="5"
overflowToDisk="true"
diskSpoolBufferSizeMB="30"
maxElementsOnDisk="10"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="3600"
memoryStoreEvictionPolicy="LRU"
clearOnFlush="true"
/>
<cache name="app1cache"
maxElementsInMemory="5"
eternal="false"
timeToIdleSeconds="60"
timeToLiveSeconds="5"
overflowToDisk="false"
diskSpoolBufferSizeMB="30"
maxElementsOnDisk="10"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="3600"
memoryStoreEvictionPolicy="LRU"
clearOnFlush="true"/>
</ehcache>this.name ="Object Operations";
this.s3.accessKeyId = "key_ID";
this.s3.awsSecretKey = "secret_key";
this.s3.defaultLocation="location";
</cfscript><cffile action="write" output="S3 Specifications" file="s3://accessKeyID:awsSecretKey@bucket/x/y/sample.txt"/>this.s3.minsizeformultipart=filesize _in_MB| Operation | Tag used | Function | Example |
Create | cfdirectory action="create" The directory attribute can only take the path of the bucket. Any additional path results in an error. All other attributes are ignored. While creating S3 bucket, the default bucket location is US . You can change the location using the attribute storeLocation. storeLocation is a new attribute added to the cfdirectory tag. You can specify ACL for the bucket while creating it using the storeACL attribute which takes a struct value. For details, see Setting up access control in Optimizing ColdFusion applications . | DirectoryCreate | <cfdirectory action="create" directory="s3://bucket1"/> |
List keys | cfdirectory action="list" | DirectoryList | <cfdirectory action="list" directory="s3://bucket1/X/y" /> Since Amazon S3 does not have the concept of directory , it returns the key name (that is, the full path) of objects contained in the bucket. Directory attribute in this case takes the path, for example, s3://bucket1 in which objects have to be searched. The path that follows the bucket name is used as a prefix to perform the list operation and all the objects that match the prefix are returned. In this case, the following attributes are ignored: recurse, type, and sort. |
Delete | cfdirectory action="delete" | DirectoryDelete | <cfdirectory action="delete" directory="s3://bucket1"/> |
| Operation | Tag used | Function | Example |
Read | cffile action="read" | FileRead | <cffile action="read" file="s3://testbucket/test.txt" variable="data"/> |
Write | cffile action="write" | FileWrite | <cffile action="write" output="#data#" file="s3://testbucket/test.txt"/> |
Delete | cffile action="delete" | FileDelete | <cffile action="delete" file="s3://testbucket/test.txt"/> |
Copy | cffile action="copy" | FileCopy | <cffile action="copy" source="s3://testbucket/test.txt" destination="s3://bucket2/a/b.txt"/> |
| Attribute Added | Description | Example |
storeLocation | Used to change the location of the created bucket. The location can either be EU or US. The default location is US . | <cfdirectory action="create" directory="s3://<bucketname>" storelocation="US"> <cfdirectory action="create" directory="s3://<bucketname>" storelocation="EU"> |
storeACL | An array of struct where each struct represents a permission or grant as discussed in aclObject. | <cfdirectory action="create" directory="s3://<bucketname>" storeACL="aclObject"> |
owner_full = {email="xxx@yyy.com", permission="full_control"};
aclObj = [owner_full, all_read];| Parameter | Description |
url | Amazon S3 URLs (content or object) |
ACLObject | An array of struct where each struct represents a permission or grant as discussed in ACLObject . |
<cfset dir = "s3://bucket_name">
<cfif !directoryExists(dir)>
<cfset directorycreate(dir)>
</cfif>
<cfset perm = structnew()>
<cfset perm.group = "all">
<cfset perm.permission = "read">
<cfset perm1 = structnew()>
<cfset perm1.email = "email ID">
<cfset perm1.permission = "FULL_CONTROL">
<cfset myarrray = arrayNew(1)>
<cfset myarrray = [perm,perm1]>
<cfset fileWrite("#dir#/test.txt","This is to test all users permission")>
<cfset StoreSetACL("#dir#/textl.txt","#myarrray#")>
<cfset test = StoreGetACL ("#dirkey#/test.txt") >
<cfdump var= "test">
<cfcatch>
<cfdump var="#cfcatch#">
</cfcatch>
</cftry>| Parameter | Description |
url | Amazon S3 URLs (content or object). |
ACLObject | An array of struct where each struct represents a permission or grant as discussed in ACLObject . |
<cfset dir = "s3://bucket_name/">
<cfset perm = structnew()>
<cfset perm.group = "authenticated">
<cfset perm.permission = "READ">
<cfset perm1 = structnew()>
<cfset perm1.email = "email_ID">
<cfset perm1.permission = "READ_ACP">
<cfset myarrray = [perm,perm1]>
<cfif NOT DirectoryExists(dir)>
<cfset directoryCreate(dir)>
</cfif>
<cfset fileWrite("#dir#/Sample.txt","This is to test StoreAddACL")>
<cfset StoreAddACL("#dir#","#myarrray#")>
<cfset test = StoreGetACL(dirkey)>
<cfdump var="#test#">
<cfcatch>
<cfdump var="#cfcatch#">
</cfcatch>
</cftry>| Parameter | Description |
url | Amazon S3 URLs (content or object) |
<cfset dir = "s3://bucket_Name">
<cfif NOT DirectoryExists(dir)>
<cfset directoryCreate(dir)>
</cfif>
<cfset test = StoreGetACL("#dir#")>
<cfdump var="#test#">| Parameter | Description |
url | Amazon S3 URLs (bucket or object). |
<cfdump var = #StoreGetMetadata("bucket_Name")#>| Parameter | Description |
url | Amazon S3 URLs (bucket or object). |
struct | Represents the metadata. See Standard keys (in this page) for a list of standard keys in metadata.You can also have custom metadata apart from the standard ones. |
mydate = #Now()#;
hello = structNew();
hello.color = "grey";
/cfscript>
<cfset dir = "s3://mycfbucket">
<cffile action="write" file="#dir#/hello5.txt" output="Sample s3 text">
<cfset StoreSetMetadata("#dir#/hello5.txt","#hello#")>
<cfset test = StoreGetMetadata("#dir#/hello5.txt")>
<cfdump var="#test#">| fileOpen | fileClose | fileCopy | fileDelete |
fileExists | fileisEOF | fileMove | fileWrite |
fileRead | fileReadBinary | fileReadLine | fileSetLastModified |
getFileInfo | getDirectoryFromPath | directoryCreate | directoryDelete |
directoryExists | directoryList | imageNew | imageRead |
imageWrite | imageWriteBase64 | isImageFile | isPDFFile |
| All cffile actions | All cfdirectory actions (except rename) | cfdocument | cffeed |
cfftp | cfimage | cfloop | All cfimage actions |
file="ram:///filename.cfm"/><cfinclude template="/inmemory/filename.cfm"><cffile action="append" file="ram:///a/b/dynamic.cfm" output="I'm appending"><cffile action="readBinary" variable="myImage" file="#ExpandPath('./')#/blue.jpg">
<cffile action="write" output="#myImage#" file="ram:///a.jpg">
<cfif FileExists("ram:///a.jpg")>
<cfoutput>a.jpg exists</cfoutput>
<cfelse>
<cfoutput>a.jpg Doesn't exists</cfoutput>
</cfif>file="ram:///filename.cfc"/><cfset cfc=CreateObject("component","inmemory.filename")/><cffile action="read" file="#ExpandPath('./')#/dynamic.cfc" variable="Message">
<cffile action="write" file="ram:///cfc/dynamic.cfc" output="#Message#"><cfinvokeargument name="paramOne" value="hello">
</cfinvoke>
<cfoutput>#returnVariable#</cfoutput></cfcomponent><cffile action="write" file="ram:///a.txt" output="Testing the function FileSetLastModified">
<cfset date="12/12/2007">
<cfscript>
FileSetLastModified("ram:///a.txt", "#date#");
sleep(1000);
WriteOutput(#GetFileInfo("ram:///a.txt").lastmodified#);
</cfscript>
<cfcatch>
<cfset PrintException(cfcatch)>
</cfcatch>
</cftry>
<cf_expectedresults>{ts '2007-12-12 00:00:00'}
</cf_expectedresults><cfdirectory action = "create" directory = "ram://src" >
<cfdirectory action = "create" directory = "ram://des" >
<cfdirectory action = "rename" directory = "ram:///CurrentDir" newDirectory = "NewDir">
<cfdirectory action="list" directory="ram://" name="listDir" recurse="yes" >
<cfdump var="#listDir#">
<cffile action="write" file = "ram://src/test.txt" output = "Release Description">
<cffile action="copy" source="ram://src/test.txt" destination="ram://des/final.txt" >
<cffile action="rename" source = "ram:///src/message.txt" destination = "ram:///des/test.txt">
<cffile action ="move" source = "ram:///des/test.txt" destination = "c:\des\move.txt"><cfimage action="captcha" fontSize="15" width="180" height="50" text="readMe" destination="ram:///readMe.jpg"
difficulty="medium">
<cfimage source="ram://aiden02.png" action="convert" destination="#ExpandPath("./")#/blue1.JPG" overwrite="yes">
<cfdocument format="pdf" filename="ram://Sample.pdf" overwrite="yes">Sample Text</cfdocument><cfcontent file="ram:///a.jpg" type="image/jpeg" deletefile="yes"><cfreport format="PDF" template="ram:///myReport1.cfr" filename="ram:///test.pdf" overwrite="yes"><cfimport prefix="custom" taglib="ram:///a/b/mytags.jar"><cffile action="rename" source="ram:///src1/message2.txt" destination="#ExpandPath('./')#/123.txt">.<cfexecute name="C:\WINDOWS\System32\netstat.exe" arguments="-e" outputFile="ram:///output.txt" timeout="1">
</cfexecute>
<cfset thisPath=ExpandPath("*.*")>| Variable | Description |
this.inmemoryfilesystem.enabled | Set the value to true to enable in-memory file system for application . This is the default setting. |
this.inmemoryfilesystem.size | Specify the memory limit in MB for the in-memory file system.You can also specify the value in the ColdFusion Administrator (Server Settings > Settings > Memory Limit per Application for In-Memory Virtual File System).The lesser value is considered. |
action = "read"
file = "ftp://Administrator:Password@Host_Name/ReadmeLater.htm" variable = "varvar">
<cffile action="write" file="ftp://Administrator:Password@Host_Name/ReadmeLater.htm" output="new stuff added">action = "read"
file="zip:#ExpandPath('./')#/hello.zip!/hello.txt"
variable = "varRead1"><cfstoredproc procedure = "foo_proc" dataSource = "MY_SYBASE_TEST"
username = "sa" password = "" returnCode = "Yes">
<!--- cfprocresult tags --->
<cfprocresult name = RS1>
<cfprocresult name = RS3 resultSet = 3>
<!--- cfprocparam tags --->
<cfprocparam type = "IN"
CFSQLType = CF_SQL_INTEGER
value = "1">
<cfprocparam type = "OUT" CFSQLType = CF_SQL_DATE
variable = FOO>
<!--- Close the cfstoredproc tag. --->
</cfstoredproc>
<cfoutput>
The output param value: '#foo#'<br>
</cfoutput>
<h3>The Results Information</h3>
<cfoutput query = RS1>
#name#,#DATE_COL#<br>
</cfoutput>
<br>
<cfoutput>
<hr>
Record Count: #RS1.recordCount#<br>
Columns: #RS1.columnList#<br>
<hr>
</cfoutput>
<cfoutput query = RS3>
#col1#,#col2#,#col3#<br>
</cfoutput>
<br>
<cfoutput>
<hr><br>
Record Count: #RS3.recordCount#<br>
Columns: #RS3.columnList#<br>
<hr>
The return code for the stored procedure is: '#cfstoredproc.statusCode#'<br>
</cfoutput>| Code | Description |
<cfstoredproc procedure = "foo_proc" dataSource = "MY_SYBASE_TEST" username = "sa" password = "" returnCode = "Yes"> | Runs the stored procedure foo_proc on the MY_SYBASE_TEST data source. Populates the cfstoredproc statusCode variable with the status code returned by stored procedure. |
<cfprocresult name = RS3 resultSet = 3> | Gets two record sets from the stored procedure: the first and third result sets it returns. |
<!--- Close the cfstoredproc tag. ---> </cfstoredproc> | Specifies two parameters for the stored procedure, an input parameter and an output parameter. Sets the input parameter to 1 and the ColdFusion variable that gets the output to FOO.Ends the cfstoredproc tag body. |
</cfoutput> <h3>The Results Information</h3> <cfoutput query = RS1> #name#,#DATE_COL#<br> </cfoutput> <br> <cfoutput> <hr> Record Count: #RS1.recordCount#<br> Columns: #RS1.columnList#<br> <hr> </cfoutput> <cfoutput query = RS3> #col1#,#col2#,#col3#<br> </cfoutput> <br> <cfoutput> <hr><br> Record Count: #RS3.recordCount#<br> Columns: #RS3.columnList#<br> <hr> The return code for the stored procedure is: '#cfstoredproc.statusCode#'<br> </cfoutput> | Displays the results of running the stored procedure:
|
cachedWithin="#CreateTimeSpan(0,1,0,0)#">
SELECT * FROM Employees
</cfquery>