[cfaussie] Re: CF702 - cfquery caching

2008-04-07 Thread KNOTT, Brian
Just create 2 separate queries with cfif tags around them.  It means you will 
have 2 separate queries but its easier to understand.

 

e.g.

 

cfif date is last month

cfquery name-blah cachewithin ...

 

/cfquery

cfelse

!--- this month query -à

cfquery name-blah cachewithin ...

 

/cfquery

 

/cfif

 

 

Thanks

 

Brian Knott

 

From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of AJ Mercer
Sent: Tuesday, 8 April 2008 11:26 AM
To: cfaussie@googlegroups.com
Subject: [cfaussie] CF702 - cfquery caching

 

Hi Fusioneers,

I have an SQL I would like to cache, but have two strategies depending on the 
parameters

If the parameters are for the current month, I only want to cache the query for 
1 day
If it is for a past month, I want to start the caching from after the last day 
of that month

cfquery has two attributes to do this
- cachedwithin
- cachedafter

So I thought I would do this, but it looks like CF does not like the CFIF 
inside the cfquery tag
cfset rptDate = CreateDate(URL.year, URL.month, DaysInMonth(Now())) /

cfquery name=qryStatsByMonth 
 datasource=#APPLICATION.DataSourceMain# 
cfif DateDiff('m', rptDate, Now()) EQ 0 
  cachedwithin=#CreateTimeSpan(1,0,0,0)# 
cfelse 
   cachedafter=#rptDate# 
/cfif 
 

Any ideas how I can do this?

For now, I will put the cfif on the outside and have two cfqueries.
Guess this is not a bad way of doing it, just thought it would be neat if it 
could be done with one query.

-- 

AJ Mercer
Web Log: http://webonix.net


---
This e-mail is sent by Suncorp-Metway Limited ABN 66 010 831 722 or one of its 
related entities Suncorp. 

Suncorp may be contacted at Level 18, 36 Wickham Terrace, Brisbane or on 13 11 
55  or at suncorp.com.au.

The content of this e-mail is the view of the sender or stated author and does 
not necessarily reflect the view of Suncorp. The content, including 
attachments, is a confidential communication between Suncorp and the intended 
recipient. If you are not the intended recipient, any use, interference with, 
disclosure or copying of this e-mail, including attachments, is unauthorised 
and expressly prohibited. If you have received this e-mail in error please 
contact the sender immediately and delete the e-mail and any attachments from 
your system.

If this e-mail constitutes a commercial message of a type that you no longer 
wish to receive please reply to this e-mail by typing Unsubscribe in the 
subject line.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
cfaussie group.
To post to this group, send email to cfaussie@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cfaussie?hl=en
-~--~~~~--~~--~--~---



[cfaussie] Re: CF702 - cfquery caching

2008-04-07 Thread Joel Cass
This makes no sense:

 

If it is for a past month, I want to start the caching from after the
last day of that month

 

You are already *after* the last day of the previous month. Having such
a statement is unnecessary.

 

Just use the cachedwithin parameter and be done with it. It's a good
idea not to store caches in memory for too long (e.g. more than a day).

 

Otherwise, create a method for caching your queries based on parameters.
Store them in memory (e.g. application scope) or save them to file (e.g.
WDDX). At least that way you have full control over when and how your
queries are cached.

Joel Cass Developer

Gruden - Design | Development | Implementation
t +61 2 9299 9462 f +61 2 9299 9463 m 0414 688 774 www.gruden.com
http://www.gruden.com/  



From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of AJ Mercer
Sent: Tuesday, 8 April 2008 11:26 AM
To: cfaussie@googlegroups.com
Subject: [cfaussie] CF702 - cfquery caching

 

Hi Fusioneers,

I have an SQL I would like to cache, but have two strategies depending
on the parameters

If the parameters are for the current month, I only want to cache the
query for 1 day
If it is for a past month, I want to start the caching from after the
last day of that month

cfquery has two attributes to do this
- cachedwithin
- cachedafter

So I thought I would do this, but it looks like CF does not like the
CFIF inside the cfquery tag
cfset rptDate = CreateDate(URL.year, URL.month, DaysInMonth(Now()))
/

cfquery name=qryStatsByMonth 
 datasource=#APPLICATION.DataSourceMain# 
cfif DateDiff('m', rptDate, Now()) EQ 0 
  cachedwithin=#CreateTimeSpan(1,0,0,0)# 
cfelse 
   cachedafter=#rptDate# 
/cfif 
 

Any ideas how I can do this?

For now, I will put the cfif on the outside and have two cfqueries.
Guess this is not a bad way of doing it, just thought it would be neat
if it could be done with one query.

-- 

AJ Mercer
Web Log: http://webonix.net


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
cfaussie group.
To post to this group, send email to cfaussie@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cfaussie?hl=en
-~--~~~~--~~--~--~---



[cfaussie] Re: CF702 - cfquery caching

2008-04-07 Thread AJ Mercer
For the current month, I still want some caching - one days worth

On Tue, Apr 8, 2008 at 9:44 AM, Joel Cass [EMAIL PROTECTED] wrote:

  This makes no sense:



 If it is for a past month, I want to start the caching from after the
 last day of that month



 You are already *after* the last day of the previous month. Having such a
 statement is unnecessary.



 Just use the cachedwithin parameter and be done with it. It's a good idea
 not to store caches in memory for too long (e.g. more than a day).



 Otherwise, create a method for caching your queries based on parameters.
 Store them in memory (e.g. application scope) or save them to file (e.g.
 WDDX). At least that way you have full control over when and how your
 queries are cached.

 *Joel Cass *Developer

 *Gruden* - Design | Development | Implementation
 *t* +61 2 9299 9462 *f* +61 2 9299 9463 *m *0414 688 774 *www.gruden.com*
   --

 *From:* cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] *On
 Behalf Of *AJ Mercer
 *Sent:* Tuesday, 8 April 2008 11:26 AM
 *To:* cfaussie@googlegroups.com
 *Subject:* [cfaussie] CF702 - cfquery caching



 Hi Fusioneers,

 I have an SQL I would like to cache, but have two strategies depending on
 the parameters

 If the parameters are for the current month, I only want to cache the
 query for 1 day
 If it is for a past month, I want to start the caching from after the last
 day of that month

 cfquery has two attributes to do this
 - cachedwithin
 - cachedafter

 So I thought I would do this, but it looks like CF does not like the CFIF
 inside the cfquery tag
 cfset rptDate = CreateDate(URL.year, URL.month, DaysInMonth(Now()))
 /

 cfquery name=qryStatsByMonth
  datasource=#APPLICATION.DataSourceMain#
 cfif DateDiff('m', rptDate, Now()) EQ 0
   cachedwithin=#CreateTimeSpan(1,0,0,0)#
 cfelse
cachedafter=#rptDate#
 /cfif
  

 Any ideas how I can do this?

 For now, I will put the cfif on the outside and have two cfqueries.
 Guess this is not a bad way of doing it, just thought it would be neat if
 it could be done with one query.

 --

 AJ Mercer
 Web Log: http://webonix.net

 



-- 

AJ Mercer
Web Log: http://webonix.net

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
cfaussie group.
To post to this group, send email to cfaussie@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cfaussie?hl=en
-~--~~~~--~~--~--~---