|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Flushing Application scoped vars
Does anyone know of a good way to flush the vars stored in the applicationDowdell, Jason G 07/23/02 09:40 A Have you triedJoe Eugene 07/23/02 10:55 A HiKola Oyedeji 07/23/02 11:20 A Since variables in the application scope are stored as a session, I supposeHaggerty, Mike 07/23/02 11:21 A >Does anyone know of a good way to flush the vars stored in the applicationDave Carabetta 07/23/02 11:21 A Jason,Mark A. Kruger - CFG 07/23/02 11:21 A <cfscript>Tipton Josh (orl1jdt) 07/23/02 11:36 A This is actually a shopping cart structure that displays the itemsDowdell, Jason G 07/23/02 11:54 A Yeah - I do it this way sometimes (holding a lookup query of inventory forMark A. Kruger - CFG 07/23/02 02:42 P Man I hate that, it was the data. There was data corruptionDowdell, Jason G 07/23/02 11:54 A > Does anyone know of a good way to flush the vars stored in the applicationS. Isaac Dealey 07/23/02 01:15 P > the Ap scope should be reserved for data that changesS. Isaac Dealey 07/23/02 01:17 P >>Does anyone know of a good way to flush the vars stored in the applicationS. Isaac Dealey 07/23/02 01:18 P Isaac,WebMaster 07/23/02 02:16 P > Isaac,S. Isaac Dealey 07/23/02 03:01 P Does anyone know of a good way to flush the vars stored in the application scope? I tried setting the applicationtimeout to CreateTimeSpan(0,0,0,0) and that didn't do anything. I'm not sure how cfflush works but I think that has to do with headers and not with ColdFusion cacheing. Anyway, if any of you has a good tip for this I'd appreciate it. Thanks, Jason <!--- Jason Dowdell dowdeljg@usano.ksc.nasa.gov 321.799.6845 IM AES - Web Developer ---> Have you tried <CFAPPLICATION NAME="YourAppName" SESSIONTIMEOUT="#CreateTimeSpan(0,0,0,0)#" APPLICATIONTIMEOUT="#CreateTimeSpan(0,0,0,0)#"> This should work Joe > Does anyone know of a good way to flush the vars stored in the application > scope? I tried setting the applicationtimeout to CreateTimeSpan(0,0,0,0) > and > that didn't do anything. I'm not sure how cfflush works but I think that > has to > do with headers and not with ColdFusion cacheing. Anyway, if any of you has ----- Excess quoted text cut - see Original Post for more ----- Hi Hi I think the application scope may be stored internally as a structure so perhaps trying a structclear would achieve this? Also not sure if the presence of cfid and cftoken on the clients machine may still cause the application to persist. Kola Does anyone know of a good way to flush the vars stored in the application scope? I tried setting the applicationtimeout to CreateTimeSpan(0,0,0,0) and that didn't do anything. I'm not sure how cfflush works but I think that has to do with headers and not with ColdFusion cacheing. Anyway, if any of you has a good tip for this I'd appreciate it. Thanks, Jason <!--- Jason Dowdell dowdeljg@usano.ksc.nasa.gov 321.799.6845 IM AES - Web Developer ---> Since variables in the application scope are stored as a session, I suppose you could do something like this: <cfset temp = structkeylist(application)> <cfloop list="#temp#" index="dex"> <cfset temp2 = structdelete(application, dex)> </cfloop> This will remove all variables from the application scope. M Does anyone know of a good way to flush the vars stored in the application scope? I tried setting the applicationtimeout to CreateTimeSpan(0,0,0,0) and that didn't do anything. I'm not sure how cfflush works but I think that has to do with headers and not with ColdFusion cacheing. Anyway, if any of you has a good tip for this I'd appreciate it. Thanks, Jason <!--- Jason Dowdell dowdeljg@usano.ksc.nasa.gov 321.799.6845 IM AES - Web Developer ---> ----- Excess quoted text cut - see Original Post for more ----- Since the APPLICATION scope is a structure, just use StructClear(APPLICATION), and that will do it. Regards, Dave. Jason, You could loop through the scope (it's a structure) and delete the keys - they would be instantiated on the next request. Note: if you have to do this routinely then you are probably using the wrong scope. the Ap scope should be reserved for data that changes very rarely (like lookup queries or Datasource names). -mk Mark A. Kruger, MCSE, CFG www.cfwebtools.com www.necfug.com ...no more brochures! Does anyone know of a good way to flush the vars stored in the application scope? I tried setting the applicationtimeout to CreateTimeSpan(0,0,0,0) and that didn't do anything. I'm not sure how cfflush works but I think that has to do with headers and not with ColdFusion cacheing. Anyway, if any of you has a good tip for this I'd appreciate it. Thanks, Jason <!--- Jason Dowdell dowdeljg@usano.ksc.nasa.gov 321.799.6845 IM AES - Web Developer ---> <cfscript> structclear(application); structclear(session); </cfscript> Does anyone know of a good way to flush the vars stored in the application scope? I tried setting the applicationtimeout to CreateTimeSpan(0,0,0,0) and that didn't do anything. I'm not sure how cfflush works but I think that has to do with headers and not with ColdFusion cacheing. Anyway, if any of you has a good tip for this I'd appreciate it. Thanks, Jason <!--- Jason Dowdell dowdeljg@usano.ksc.nasa.gov 321.799.6845 IM AES - Web Developer ---> This is actually a shopping cart structure that displays the items in each category, subcategory or brand. The structure only gets deleted if the owner of the store updates the database of products and then I set a flag. I knew about deleting and clearing the structure but it wasn't working. I think my problem was that I didn't get rid of the cookies on my machine but I'm checking that now. ~Jason Jason, You could loop through the scope (it's a structure) and delete the keys - they would be instantiated on the next request. Note: if you have to do this routinely then you are probably using the wrong scope. the Ap scope should be reserved for data that changes very rarely (like lookup queries or Datasource names). -mk Mark A. Kruger, MCSE, CFG www.cfwebtools.com www.necfug.com ..no more brochures! Does anyone know of a good way to flush the vars stored in the application scope? I tried setting the applicationtimeout to CreateTimeSpan(0,0,0,0) and that didn't do anything. I'm not sure how cfflush works but I think that has to do with headers and not with ColdFusion cacheing. Anyway, if any of you has a good tip for this I'd appreciate it. Thanks, Jason <!--- Jason Dowdell dowdeljg@usano.ksc.nasa.gov 321.799.6845 IM AES - Web Developer ---> Yeah - I do it this way sometimes (holding a lookup query of inventory for example). Some times I do something like this: <cfif NOT IsDefined('application.*somekey*') OR IsDefined('url.forceRefresh')> <cflock scope="application" timeout="10"> <cfquery name="application.Inventory" datasource="MyDsn"> SELECT * FROM inventory_table </cfquery> </cflock> </cfif> Then, I (or even my client) can just hit any page in the ap with ?forcerefresh=true appended to the URL - and viola! the application vars are refreshed. -mk This is actually a shopping cart structure that displays the items in each category, subcategory or brand. The structure only gets deleted if the owner of the store updates the database of products and then I set a flag. I knew about deleting and clearing the structure but it wasn't working. I think my problem was that I didn't get rid of the cookies on my machine but I'm checking that now. ~Jason Jason, You could loop through the scope (it's a structure) and delete the keys - they would be instantiated on the next request. Note: if you have to do this routinely then you are probably using the wrong scope. the Ap scope should be reserved for data that changes very rarely (like lookup queries or Datasource names). -mk Mark A. Kruger, MCSE, CFG www.cfwebtools.com www.necfug.com .no more brochures! Does anyone know of a good way to flush the vars stored in the application scope? I tried setting the applicationtimeout to CreateTimeSpan(0,0,0,0) and that didn't do anything. I'm not sure how cfflush works but I think that has to do with headers and not with ColdFusion cacheing. Anyway, if any of you has a good tip for this I'd appreciate it. Thanks, Jason <!--- Jason Dowdell dowdeljg@usano.ksc.nasa.gov 321.799.6845 IM AES - Web Developer ---> Man I hate that, it was the data. There was data corruption in the database and that screwed it all up. thanks guys, Jason ----- Excess quoted text cut - see Original Post for more ----- Since the APPLICATION scope is a structure, just use StructClear(APPLICATION), and that will do it. Regards, Dave. ----- Excess quoted text cut - see Original Post for more ----- <cfflush> is only indirectly related to headers -- it tells the cfserver to send whatever portion of the page has completed to the browser before continuing processing the page, so the browser gets the page incrementally... The relationship to headers is that you cant use anything on the page after a cfflush tag that would alter the headers like cfheader, cflocation and I think cfcookie and possibly cfform. As to your question, try this: <cflock scope="application" type="exclusive" timeout="10"> <cfscript> temp = application.applicationname; StructClear(application); application.applicationname = temp; </cfscript> </cflock> That should give you a clean-slate, just as tho the <cfapplication> tag had just been processed for the first time. Isaac Dealey www.turnkey.to 954-776-0046 > the Ap scope should be reserved for data that changes > very rarely (like ...<snip>... Datasource names). ICK! ... I had to clean up someone else's mess recently with this -- they used application variables for all their db accessing variables ( dsn, username and password ) and with zero locking on a heavily trafficked CF5 server... which of course, caused problems... I replaced them all with request variables, which solved the problem. Isaac Dealey www.turnkey.to 954-776-0046 ----- Excess quoted text cut - see Original Post for more ----- I did this once ... You have to make sure you copy the applicationname into a temp variable and then copy it back into thea applicationscope afterward on the same page... I'm not real certain why, but you get an error on the next page otherwise ... or at least that was the result I got... Isaac Dealey www.turnkey.to 954-776-0046 Isaac, What is wrong with using application scope to hold the user name and password? ----- Excess quoted text cut - see Original Post for more ----- > Isaac, > What is wrong with using application scope > to hold the [cfquery] user name and password? There's nothing necessarily wrong with it per se ... The problem here in particular was that there wasn't any use of <cflock> in the application on a heavily trafficked CF5 server, which caused server instability ... So the options were to either read-lock the application scope on every one of several hundred cfqueries or simply replace "application" with "request" in the cfset tags and then again in all the queries ... the latter solution is _MUCH_ less code, much easier to do to fix the problem, and probably better performance as well, since it eliminates the problem of the machine waiting for any pages loading queries to finish with the db before being able to instantiate an exclusive lock to set the application variable equal to what it's already equal to anyway. :) I could have even set a request variable equal to the application variable on each page request, but even that would have been gratuitous code / locking. My inclination is to think that in the majority of applications ( well, it has been in all the applications I've ever worked on ) that the data accessing variables used for cfquery and cfstoredproc tags are defined only once in either the application.cfm or the fbx_settings ( or equivalent fusebox2 module ) ... at which point, the code which generates these variables is going to be included on every page request anyway, so using the application scope to store it is gratuitous unless you plan to change these variables on the fly, _without_ editing the application.cfm or fbx_settings.cfm file... I can _imagine_ situations in which someone might want to do this, but I've never worked with one. Isaac Dealey www.turnkey.to 954-776-0046
|
May 19, 2013
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||