Answered
Component in Application Scope and cflock
Hi,
I have an CFC that I set in application scope in the onApplicationStart method which contains some system parameters, one of which is a flag saying whether the site is currently "Online". I call a method on this CFC in the Application.cfc "onRequest" method to see if the flag value has changed.
This method looks up a parameter set in the database that says whether the site is "online" or "offline". If the site is currently online, I want to only redo the query every 5 mins. However if the site is offline, I want to check more frequently (every 5 secs) as to whether the flag has changed back.
What I am not sure of, is whether I need to be using <cflock> when I change from "online" to "offline"? There is only a single instance of this object, but what happens if multiple requests are calling the "isSiteOnline" method simultaneously? Is this "safe"?
Some code snippets are attached to illustrate.
Any advice would be greatly appreciated.
Regards,
Andrew.
I have an CFC that I set in application scope in the onApplicationStart method which contains some system parameters, one of which is a flag saying whether the site is currently "Online". I call a method on this CFC in the Application.cfc "onRequest" method to see if the flag value has changed.
This method looks up a parameter set in the database that says whether the site is "online" or "offline". If the site is currently online, I want to only redo the query every 5 mins. However if the site is offline, I want to check more frequently (every 5 secs) as to whether the flag has changed back.
What I am not sure of, is whether I need to be using <cflock> when I change from "online" to "offline"? There is only a single instance of this object, but what happens if multiple requests are calling the "isSiteOnline" method simultaneously? Is this "safe"?
Some code snippets are attached to illustrate.
Any advice would be greatly appreciated.
Regards,
Andrew.
