CF10 reusing cfc functions
Hi All,
I have two cfc files, the first file contain a very large calculation in couple functions. In the second file I have multiple functions and they are using the calculations from the first cfc file. The issue is now performance because I am calling the functions from the first cfc multiple times from the second cfc.
The functions on the second cfc are called from methods in flex passing parameters and the result of each function on the second cfc will be fill an arraycollection.
It is a way to capture the result from the first cfc and use this from the second cfc without multiple calls?
Any ideas in how to improve my performance?
Thanks
Here is an example of my code:
<cfcomponent name="firstComp" output="false">
<cffunction name="getCostCalculation" output="false" access="remote">
<cfargument name="arg_id" type="numeric" required="yes" />
<cfargument name="place_id" type="numeric" required="yes" />
<cfargument name="start_year" type="numeric" required="yes" />
<cfargument name="end_year" type="numeric" required="yes" />
<!--- Many calculations calling the database --->
<cfreturn result>
</cffunction>
</cfcomponent>
<cfcomponent name="secondComp" output="false">
<cffunction name="getFirstCalculation" output="false" access="remote">
<cfargument name="arg_id" type="numeric" required="yes" />
<cfargument name="place_id" type="numeric" required="yes" />
<cfquery name="getYears" datasource="#application.str_dsn#">
select fydp_startyear, fydp_endyear
from myCost
where req_id = #arguments.arg_id#
</cfquery>
<cfset myObj = CreateObject("component", "firstComp") />
<cfset costResult = myObj.getCostCalculation(arguments.arg_id, arguments.place_id, getYears.fydp_startyear, getYears.fydp_endyear) />
<cfquery dbtype="query" name="resultApp">
select someFields
from costResult
</cfquery>
<!--- Many calculations--->
<cfreturn result>
</cffunction>
<cffunction name="getSecondCalculation" output="false" access="remote">
<cfargument name="arg_id" type="numeric" required="yes" />
<cfargument name="place_id" type="numeric" required="yes" />
<cfquery name="getYears" datasource="#application.str_dsn#">
select fydp_startyear, fydp_endyear
from myCost
where req_id = #arguments.arg_id#
</cfquery>
<cfset myObj = CreateObject("component", "firstComp") />
<cfset costResult = myObj.getCostCalculation(arguments.arg_id, arguments.place_id, getYears.fydp_startyear, getYears.fydp_endyear) />
<cfquery dbtype="query" name="resultApp">
select otherFields
from costResult
</cfquery>
<!--- Many calculations --->
<cfreturn result>
</cffunction>
</cfcomponent>
