You could have a block of code inside of OnApplicationStart where all
the query caching takes place, and put a cflock around that block of
code, instead of altering all 55 queries. If the queries are cached
OnApplicationStart, I would have high confidence that you wouldn't
need to lock them when used in the site. The thing to watch out for is
that you will need some code to refresh the cache, in case you want to
change the content of the drop down list without waiting for a service
restart. If someone loads a drop down list while you are refreshing
the cache, then they could see a list that only has half the entries
it should. The risk of this depends on how often you would have to
update the cache while the site is being actively used. A list showing
50 states probably doesn't change much.
Also, if you are running CF8, maybe this query loading code is a good
chance to experiment with the cfthread tag, since I bet the queries
are independent.
-Mike Chabot
On 10/25/07, Rick Root <[EMAIL PROTECTED]> wrote:
> 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
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion 8 - Build next generation apps
today, with easy PDF and Ajax features - download now
http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:292053
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4