modifying cache times based on API call

2012-10-14 Thread Greg Skerman
Hi,

I am connecting an API which provides values that are intended to instruct
the consumer on how long to cache a result for. Different API calls have
different cache times (and these cache times may be variable, so setting up
a config for each possible outcome is out of the question).

Essentially there is a callTime and a cacheTime value in the response -
callTime is the server timestamp that the data was retrieved, and cacheTime
is the server timestamp that I am expected to wait until I make the next
call.

Now, I can easily perform some date math here to figure out the cache time
and plug it into cache::set before writing my local cache - but whilst
reading the caching documentation on the subject I discovered this:

*If you use Cache::set() to change the settings for a write, you should
also use Cache::set() before reading the data back in. If you fail to do
so, the default settings will be used when the cache key is read.:*

How does one get around this? I cannot know the cache duration until
*after* I have read the value - and if the default is used there is a good
chance that the value will be prematurely garbage collected. If I set the
default value to an obscenely long time (upwards of 24 hours), then I run
the risk that the cache will *never* be garbage collected.

Do I need to store a key map somewhere that describes the cache time
values so I can look them up? or is there a way to inspect the cache time
before reading the value?

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: Set::sort Help

2012-10-14 Thread lowpass
Give each company a slug so that they're all normalised to lowercase
and sort on that.

This would also allow you to have routes like '/companies/:slug'

On Sat, Oct 13, 2012 at 6:35 PM, Advantage+ movepix...@gmail.com wrote:
 I have :



 $all[$key] = Set::sort( $master[$key], '{n}.name', 'asc');



 Which sorts my extracts alphabetically.

 Only problem is that it the '{n}.name' in the database are both upper and
 lowercase because they are brand / company names so they must be entered in
 correct case.



 So when it sorts it does the uppercase A-Z then follow the lowercase a-z. So
 it is not sorting as I would like.

 Should be Aa - Zz.

 How can it sort so it is not case sensitive?



 Thanks,

 Dave

 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




xml format problem

2012-10-14 Thread Robert Gravel
Hello i am using 1.3

I am trying to get this format from my array.

array(
'Response' = array(
  'Sms' = 'Thank you!',
)
  )

response
SmsThank you!/Sms
/response

but after trying (see below) I can't get that output. Is there a way to do 
this?


?php 
echo $this-Xml-header(); 
echo $this-Xml-serialize($response); 
? 

?xml version=1.0 encoding=UTF-8 ?
  response Sms=Thank you! /

and

?php
echo $this-Xml-header();
echo $xml-serialize($response, array('format' = 'tags'));
?


?xml version=1.0 encoding=UTF-8 ?
- response
- Sms
- ![CDATA[ Thank you!
  ]]
  /Sms
  /response

Thanks Robert

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: xml format problem

2012-10-14 Thread lowpass
What's the problem exactly? Is it the CDATA block? The ?xml tag?

On Sun, Oct 14, 2012 at 3:08 PM, Robert Gravel rockb...@gmail.com wrote:
 Hello i am using 1.3

 I am trying to get this format from my array.

 array(
 'Response' = array(
   'Sms' = 'Thank you!',
 )
   )

 response
 SmsThank you!/Sms
 /response

 but after trying (see below) I can't get that output. Is there a way to do
 this?


 ?php
 echo $this-Xml-header();
 echo $this-Xml-serialize($response);
 ?

 ?xml version=1.0 encoding=UTF-8 ?
   response Sms=Thank you! /

 and

 ?php
 echo $this-Xml-header();
 echo $xml-serialize($response, array('format' = 'tags'));
 ?


 ?xml version=1.0 encoding=UTF-8 ?
 - response
 - Sms
 - ![CDATA[ Thank you!
   ]]
   /Sms
   /response

 Thanks Robert

 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: xml format problem

2012-10-14 Thread Robert Gravel
 I do not need the extra   CDATA markup . I only need the Response and
Sms open and close tags along with my text

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




RE: Set::sort Help

2012-10-14 Thread Advantage+
Great suggestion!
Added a slug in the db and made all lower case, sorted that then used
thename to display.

Thanks,
Dave

-Original Message-
From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf
Of lowpass
Sent: Sunday, October 14, 2012 3:21 PM
To: cake-php@googlegroups.com
Subject: Re: Set::sort Help

Give each company a slug so that they're all normalised to lowercase and
sort on that.

This would also allow you to have routes like '/companies/:slug'

On Sat, Oct 13, 2012 at 6:35 PM, Advantage+ movepix...@gmail.com wrote:
 I have :



 $all[$key] = Set::sort( $master[$key], '{n}.name', 'asc');



 Which sorts my extracts alphabetically.

 Only problem is that it the '{n}.name' in the database are both upper 
 and lowercase because they are brand / company names so they must be 
 entered in correct case.



 So when it sorts it does the uppercase A-Z then follow the lowercase 
 a-z. So it is not sorting as I would like.

 Should be Aa - Zz.

 How can it sort so it is not case sensitive?



 Thanks,

 Dave

 --
 Like Us on FaceBook https://www.facebook.com/CakePHP Find us on 
 Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google 
 Groups CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.



--
Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter
http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.



-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




why cakephp doesn't support pure MVC

2012-10-14 Thread Ashish Mahana
if we declare a variable inside a model then we are unable to fetch its 
value in controller

e.g.  

Model M code:

class M extends AppModel
{
   var $x;


function setX(){
$this-x = hello;
}
function getX(){
return $this-x;
}

}


controller M code

class M_controller extends AppController{

$this-M-setM();

$c = $this-M-getX();



}

when i check the $c in view page its blank 

can anybody explain what is happening over here

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: why cakephp doesn't support pure MVC

2012-10-14 Thread sutikno sofjan
controller M code

class M_controller extends AppController{

$this-M-setM();   This is wrong. $this-M-setX();

$c = $this-M-getX();



}


On Mon, Oct 15, 2012 at 12:57 AM, Ashish Mahana ashish.mah...@gmail.comwrote:

 if we declare a variable inside a model then we are unable to fetch its
 value in controller

 e.g.

 Model M code:

 class M extends AppModel
 {
var $x;


 function setX(){
 $this-x = hello;
 }
 function getX(){
 return $this-x;
 }

 }


 controller M code

 class M_controller extends AppController{

 $this-M-setM();

 $c = $this-M-getX();



 }

 when i check the $c in view page its blank

 can anybody explain what is happening over here

 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.




-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: why cakephp doesn't support pure MVC

2012-10-14 Thread Maliko V
He's right seems like you made a mistake calling your method with the wrong 
name :)

VM 

Sent from iPhone smartphone

On 2012-10-14, at 9:54 PM, sutikno sofjan sutikno.sof...@cic.ac.id wrote:

 controller M code
 
 class M_controller extends AppController{
 
 $this-M-setM();   This is wrong. $this-M-setX();
 
 $c = $this-M-getX();
 
 
 
 }
 
 
 On Mon, Oct 15, 2012 at 12:57 AM, Ashish Mahana ashish.mah...@gmail.com 
 wrote:
 if we declare a variable inside a model then we are unable to fetch its 
 value in controller
 
 e.g.  
 
 Model M code:
 
 class M extends AppModel
 {
var $x;
 
 
 function setX(){
 $this-x = hello;
 }
 function getX(){
 return $this-x;
 }
 
 }
 
 
 controller M code
 
 class M_controller extends AppController{
 
 $this-M-setM();
 
 $c = $this-M-getX();
 
 
 
 }
 
 when i check the $c in view page its blank 
 
 can anybody explain what is happening over here
 -- 
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP
  
 --- 
 You received this message because you are subscribed to the Google Groups 
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to 
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 -- 
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP
  
 --- 
 You received this message because you are subscribed to the Google Groups 
 CakePHP group.
 To post to this group, send email to cake-php@googlegroups.com.
 To unsubscribe from this group, send email to 
 cake-php+unsubscr...@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php?hl=en.
  
  

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.