Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
JoyRose #1
error produced from expired cached query
:rose; How can I catch the error produced when a user tries to refresh a page
that depends on a cached query to display content, once the query has expired?
I don't want to query to remain cached and return older results after the
database is updated with new info. Is there a way to check if the query has
expired and have it rerun? The queries are in an include file that is called
before the display page include file is called. Both includes are wrapped in
the same file. The query reruns after an update. I'm referring to a situation
where the user refreshes a page that relies on the results of a cached query.
They see an error when the query is expired saying there is no data to return
to the page. I'd like to intercept that error and redirect the user back to the
main page from which the query would be rerun. Thanks for any insights!
JoyRose Guest
-
Cached page and query results, help!
I have a frameset and on one frame I have a CFGrid. When I click on an entry in the grid, that same frame replaces itself with the record detail.... -
Cached query
I have got this query <CFQUERY NAME="GetImportData" DATASOURCE="ExcelNordic" USERNAME="#Application.SQLUserName#"... -
can you test for a cached query?
Is there something like IsDefined that tests for a cached query? If yes, I can use that to avoid going back to the DB. thanks in advance -brian -
expired cached query
:rose; How can I catch the error produced when a user tries to refresh a page that depends on a cached query to display content, once the query has... -
Using aggregrate function sum() from within Cached Query
Hi, I have a query which returns say total 30 records. Now, form within these 30 records, I am using another Cached query which will retrive... -
zoeski80 #2
Re: error produced from expired cached query
Hi Joy Rose
If you use the cachedwithin="#CreateTimeSpan(0,0,20,0)#" attribute in the
CFQUERY tag it will run the query if it doesn't exist or has expired otherwise
it will use the cached version. You just need to use the CreateTimeSpan
function to specify how long the query should be cached for.
If you have run a CFQUERY with CachedWithin but want to reset the query so it
will definitely rerun the query on the database you can run the exact same
query again and have CachedWithin set to -1 seconds (ie.
CreateTimeSpan(0,0,0,-1) )and it will force the cached query to be ignored and
the actual query run on the database again.
Is this what you were referring to?
HTH
Zoe
zoeski80 Guest
-
JoyRose #3
Re: error produced from expired cached query
:rose; Thank you so much for your response. Actually, I am already using
CreateTimeSpan. I think the problem may be that the query is run from an
include file that is not recalled if the user refreshes the display page
(although I would think it would since the display page is also an include on
the same page the query include is on.) I could add the query as you
suggested ((CreateTimeSpan(0,0,0,-1))into the display include but that would
clutter the code since the organization of the files is to include a query file
at a higer level page for queries related to a similar function to run from.
The query reruns fine unless the user trys to refresh the display page after
the cached query expires. If I used the ((CreateTimeSpan(0,0,0,-1)) on each
display page, that would defeat the purpose of caching the query at all. If my
assumptions are correct, I guess what I want is to catch the error and provide
the user an instruction to return to the previous page, from which the display
page under discussion is linked. Thanks for your ideas.
JoyRose Guest
-
zoeski80 #4
Re: error produced from expired cached query
Hi JoyRose
If you refresh a page all the included files should be re-run too. I don't
understand why the cached quey isn't being used or being re-run automatically
when it expires.
You could post some code and/or the actual error message so we can have a look.
If you are just using the CachedWithin parameter on the query I think there is
something wrong with the execution of the code, but if you want to leave the
code as-is and just catch the error you can put a CFTRY around the query with a
CFCATCH for all errors and display your message.
Zoe
zoeski80 Guest



Reply With Quote

