error produced from expired cached query

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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....
    2. Cached query
      I have got this query <CFQUERY NAME="GetImportData" DATASOURCE="ExcelNordic" USERNAME="#Application.SQLUserName#"...
    3. 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
    4. 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...
    5. 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...
  3. #2

    Default 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

  4. #3

    Default 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

  5. #4

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139