CFFUNCTION
Used to define a function within a CFC, or as a UserDefinedFunction (UDF) that can be used in the same context
Usage
<cffunction> ... </cffunction>
Attributes
Attribute | default | required | summary |
---|---|---|---|
NAME | The name for the method. Must not contain any spaces, or special characters (except for _) | ||
DISPLAYNAME | The name that is used to describe this function when displayed in meta data | ||
ACCESS | public | Determines who can access this function. Values: private, package, public, or remote (becomes available in a SOAP or RPC call) | |
OUTPUT | YES | Controls whether or not this CFC can generate output | |
ROLES | Comma-separated list of roles that the user must be in to be able to call this function | ||
RETURNTYPE | any | The type of data this function has to return | |
RETURNFORMAT | When called as part of a WebService RPC, determines the return format of the data. Values: PLAIN, WDDX, JSON, JSONP | ||
SECUREJSON | When called as part of a WebService RPC, will insert this token infront of the response | ||
VERIFYCLIENT | false | When called as part of the WebService RPC, ensures the client is using the encrypted token | |
JSONDATE | long | How dates should be encoded in the outgoing JSON. Values are: LONG, HTTP, JSON, CFML. You can change the default encoding using the bluedragon.xml flag: server.system.jsondate | |
JSONCASE | maintain | How to treat the case of the keys of outgoing JSON. Values are: lower, upper or maintain. You can change the default encoding using the bluedragon.xml flag: server.system.jsoncase | |
REGION | Enable per-function caching by enabling the cache. Any valid region can be used ('function' region exists for function calls). If enabled the cache key is calculated from the function name plus a hash of all the parameters passed in (only simple types are used in the form calculation) | ||
CACHEDWITHIN | -1 | The time span to which this result will be cached for before it is reexecuted. As decimal of a whole day (CreateTimeSpan()) |
Extra
Here is an example of using caching with a function call, that will cache the results for 10 seconds
<cffunction name="getTime" region="function" cachedwithin="#CreateTimeSpan(0,0,0,10)#"> <cfargument name="param1"> <cfargument name="param2"> <cfreturn now()> </cffunction> <cfloop index="x" from="1" to="25"> <cfoutput>#getTime()#</cfoutput> <cfset sleep(1000)> <cfflush> </cfloop>
For more information on using caching and setup, visit the Caching