[thelist] CF: Clearing a cached query?

Morgan Kelsey morgan at morgankelsey.com
Tue Oct 15 12:02:01 CDT 2002


> > BUT, i still find, that if i have more than one template accessing a
> > query, there's probably a better way to do it that only needs to run
> > the query once.
> okay, here's my example
> <CFQUERY NAME="navquery" DATASOURCE="#blogdsn#"
>    CACHEDWITHIN="#CreateTimeSpan(0,1,0,0)#"
>    BLOCKFACTOR="100" >
>   select nav.id           as navid
>        , nav.catseq       as navcatseq
>        , nav.catlink      as navcatlink
>        , nav.catname      as navcatname
>        , subnav.id        as subid
>        , subnav.catseq    as subcatseq
>        , subnav.catlink   as subcatlink
>        , subnav.catname   as subcatname
>     from category nav
>        , category subnav
>    where nav.cattype='nav'
>      and nav.catsite='#domain#'
>      and nav.catcatid is null
>      and nav.id = subnav.catcatid
> order by nav.catseq
>        , subnav.catseq
> the purpose of this query is to get my site's navigation structure


> this query is called on every page in my site
> (well, every page that has a nav bar, to be exact)

why don't you just stick it in Application.cfm if it runs on every (or most
every) page?

> if i change the database, every page's nav bar is changed
> after an hour, that is   ;o)
> and please don't tell me how to load stuff like this into session or
> application variables <grin>

of course not. ;o) I hardly touch the stuff myself.

> > ...  for future readability, i like to just keep it in my action
> template.
> i cannot see doing that for nav bar data, state codes, latest news lists,
> etc.

well, i would either put in application like i said, or in my design
container. You *do* have a design/container template, don't you? [grin /]

i used to "include the design" into my applications, so each page in the
site would either use a custom tag for a wrapper, or include common headers,
footers and sidebars, etc. then one day it dawned on me (well, someone
whacked me on the head with a hammer really):
it should be the other way around.
include your apps into your design. you should have one design template,
that contains all the common html. in the center of that, include your
page-specific applications.

think about it, its slightly different from the usual way of thinking.

works excellent with a custom 404 handler too....(and look i'm not trolling,
i'm gonna lay it right out :p)
your error handler generates parameters, and includes the design container.
then, the middle of the design container (where most page specific content
is), chooses which app to run based on the parameters produced by the error
make sense? you'll end up including your includes less, if that makes sense,

not a system i can take credit for creating, a wiser CFer than I turned me
onto it. but its one i happily employ, deploy, beat and berate.


More information about the thelist mailing list