I have a flex app that uses a single cfc method to populate all of its
drop down lists. The method is called getListData
It runs 55 queries, and stores the results of those queries in a
structure, and returns the structure to Flex.
This works great, but it's a performance drag - especially if 10 or
more people attempt to launch the application at the same time (like
in training).
I'm using shared objects to reduce the load on the server (the data is
only retrieved once per day).
But in an effort to improve performance, since the data being returned
is the same for *ALL* users, I'm thinking of storing the whole
structure in the application scope.
I want to do locking on this so that only one thread can access the
code within the getlistdata method at a time.... so I'm thinking of
doing something like this.
<cffunction name="getlistdata" ..>
<cfset var retVal=structNew()>
<cflock name="foo" type="exclusive">
<cfif isDefined("application.enquireListData")>
<cfreturn application.enquireListData>
<cfelse>
<cfquery name="retVal.states"...> ...</cfquery>
<cfquery name="retVal.countries"...> ...</cfquery>
<cfquery name="retVal.etc"...> ...</cfquery>
<cfset application.enquireListData = retVal>
</cfif>
</cflock>
<cfreturn retVal>
</cffunction>
So even if 10 peole access it at the same time, only the first one is
going to get the lock.. the first one will run the queries and create
the application variable, while the others wait for the lock to be
released.
The 50 queries only take about a second or two to run, so the wait for
the lock won't be that long.
Am I on the right track here?
--
Rick Root
Check out CFMBB, BlogCFM, ImageCFC, ImapCFC, CFFM, and more at
www.opensourcecf.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Check out the new features and enhancements in the
latest product release - download the "What's New PDF" now
http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:292050
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4