just to finish the thread, I've ended up not cheating and rolling my
own caching. it turns out there's more tables/CFC's that need to do
this so... (do the hard yards properly)

... called from either the init() or when getting data and checking
the use-by date first.

thanx to those who responeded.

cheers
barry.b

        <cffunction name="qGetTemplatesList" access="public" output="false"
returntype="query">
                <cfif variables.cachedata.Template.expires LT now()>
                        <!--- check to see the data is fresh enough to use, if not 
refresh it --->
                        <cfset setTemplateData() />
                </cfif>
                <cfreturn variables.cachedata.Template.query />
        </cffunction>



        <cffunction name="setTemplateCacheData" access="private"
output="false" returntype="void" hint="fills the internal query and
struct with database data, resets the expire time">
                <cfset var result = queryNew("") />
                        <!--- NOTE: "keyField" is to handle the primary key 
being numeric
(for QueryToStructOfStructures) --->
                        <cfquery name="result" 
datasource="#_config.getEvaluationsDSN()#">
                                Select ('key_' + cast(TemplateNum as varchar)) 
as keyField,
TemplateNum, ShortName, LongDesc
                                from tbl_Template
                                where Active = 1
                                order by ShortName
                        </cfquery>
                <cfset variables.cachedata.Templates.query = result />          
          
                <cfset variables.cachedata.Template.structure =
_config.QueryToStructOfStructures(result,"keyField") />
                <cfset variables.cachedata.Template.expires =
dateAdd("n",_config.getCacheDataTimeout("Template"),Now()) />
                <cfif (not _config.isProduction()) or (_config.isDebug())>      
  
                        <cfset 
_config.GetFactoryReference().getComponentLoader().GetComponent("logger").writeInformation("Template
data cached") />
                </cfif>   
        </cffunction>






On 10/4/06, Barry Beattie <[EMAIL PROTECTED]> wrote:
> Why not jus use QoQ on the cached queries, rather than converting them?
>
> May not be QUITE as fast... but?

a typical usage is processing a couple of hundred elements in an array
of structs..."if this then insert else update" sort of thing.

for each array loop iteration there's abot 6-10 lookups and decisions
to be done.

for the couple of hundred inserts and updates to process and then
redrawing the datagrid at the end (did I mention that it *should* be a
flex app with remoting... but isn't?) every bit helps. Previously,
other parts of the system just re-re-re-queried away happily.. some
with cachewithin, some with none.

yes, I can move the whole lot down to the database but the amount of
decisons, formatting and error trapping to do, it just ain't worth it.
CF is the best place to process this lot.

 > The other option is - cache both the query, and the struct version...
> and lookup depending on what you need.
>
> That means you would have to roll your own caching system such that
> when the query gets refreshed, your struct does too.

yeah, option one. I just have to guess when the data gets dirty to
re-run the caching...

cheers
b


You are subscribed to cfcdev. To unsubscribe, please follow the instructions at 
http://www.cfczone.org/listserv.cfm

CFCDev is supported by:
Katapult Media, Inc.
We are cool code geeks looking for fun projects to rock!
www.katapultmedia.com

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]




You are subscribed to cfcdev. To unsubscribe, please follow the instructions at 
http://www.cfczone.org/listserv.cfm

CFCDev is supported by:
Katapult Media, Inc.
We are cool code geeks looking for fun projects to rock!
www.katapultmedia.com

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]

Reply via email to