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.


Reply via email to