Working with Cached Queries

Add comments

In one of my assignments, I cam across a scenario where I needed to determine the time a query was cached to give the user an accurate time in which the updated data will be available. I knew the query was caches for 12 hours as the previous developer created a timespan: createTimeSpan(0, 12, 0, 0). That was helpful in knowing how long it would be cached for, but I needed to know when it would re-cache.

Through some thinking, I decided to inject the date into the query itself, and I would be able to determine the re-cache date from that like so:

SELECT Name, Description, CachedOn = getDate() FROM Material

With this method, I could always reference qryMaterials.CachedOn to determine when the query was cached, and use dateAdd() to figure out that date 12 hours from now. While I believe that was the most effective way to handle this in my situation, I did have to search into it further because it was bothering me that I couldn't get the date from CF. I decided to look around at the CF factories to see if anything there would be helpful... and what do you know! The Java class coldfusion.server.ServiceFactory contained a reference to the coldfusion.server.DataSourceService. From within this service, I was able to access all of the cached queries and get more than just the cache date.

Rather than explain explain the rest with pretty screenshots, I'll let you do the work and see exactly what's available for you. Here is a quick snippet I wrote that displays all of the queries, their names, the cached date, and a link to re-run then query manually. You can also get the ResultSet, change the ResultSet, and a few more methods that I won't discuss here. Hopefully this will be as beneficial to you as it has me.

Cached queries: #arrayLen(arQueries)#

Query: #name# (re-run)
Cached on: #cacheTime#

23 responses to “Working with Cached Queries”

  1. juwnxq Says:
    EPmNA7 vqqijrbugqjw, [url=http://kprtkfbjfoua.com/]kprtkfbjfoua[/url], [link=http://yyanlvfylkrn.com/]yyanlvfylkrn[/link], http://iuncaxvdhxwv.com/
  2. Levitra Says:
    comment6, Viagra, Levaquin, Lexapro, Ambien,
  3. cialis Says:
    comment6, Adipex, Levaquin, Xanax, Viagra,
  4. Viagra Says:
    comment1, Levitra, Rimonabant,
  5. Prednisone Says:
    comment2, Levitra, Prednisone, Levaquin,
  6. Valium Says:
    comment5, Acomplia, Levitra, Levitra, Viagra,
  7. Adipex Says:
    comment5, Adipex, viagra, Ambien,
  8. Xanax Says:
    comment1, Viagra, Lexapro, Cialis,
  9. Xanax Says:
    comment2, Levitra, Prednisone,
  10. Levitra Says:
    comment5, Cialis, Acomplia,
  11. Cialis Says:
    comment1, Levitra, Prednisone, Ambien,
  12. baclofen 10mg tablet Says:
    comment2, Cymbalta, florida accutane lawyer, Phentermine, Valtrex, Levitra, Propecia, Viagra, female viagra, Viagra,
  13. Valtrex Says:
    comment4, after bactrim effects, Metformin, Valtrex, cafergot dosing, Clomid, Cialis, Diflucan, Antabuse,
  14. alexd427 Says:
    Very nice site! is it yours too
  15. alexk317 Says:
    Very nice site! [url=http://yieapxo.com/qoqav/2.html]is it yours too[/url]
  16. alexe395 Says:
    Very nice site! is it yours too http://yieapxo.com/qoqav/4.html
  17. alexb436 Says:
    Very nice site!
  18. Pharme412 Says:
    Very nice site! is it yours too , is it yours too , is it yours too , is it yours too , is it yours too , is it yours too , is it yours too , is it yours too , is it yours too , is it yours too ,
  19. alexg199 Says:
    Very nice site! is it yours too
  20. alexb239 Says:
    Very nice site! [url=http://yieapxo.com/qoqav/2.html]is it yours too[/url]
  21. alexc379 Says:
    Very nice site! is it yours too http://yieapxo.com/qoqav/4.html
  22. alexc134 Says:
    Very nice site!
  23. Pharmk762 Says:
    Very nice site! is it yours too , is it yours too , is it yours too , is it yours too , is it yours too , is it yours too , is it yours too , is it yours too , is it yours too , is it yours too ,

Leave a Reply

Powered by Mango Blog. Design and Icons by N.Design Studio