Issue Type: Improvement Created: 2006-10-22T19:10:47.000+0000 Last Updated: 2007-07-05T14:43:23.000+0000 Status: Resolved Fix version(s): - 0.8.0 (21/Feb/07)
Reporter: Lee Saferite (lsaferite) Assignee: Fabien MARTY (fab) Tags: - Zend_Cache
Related issues: Attachments: - Zend_Cache_221006_2.diff
Currently the Zend_Cache_Backend_Interface does not allow for the possibility of having per-item lifetimes. In addition, due to the way directives are set, you cannot retrieve the current lifetime, change it, and reset it.
By adding in an additional optional variable on calls to save() on the backend, you can allow this feature and not break current usage.
Posted by Lee Saferite (lsaferite) on 2006-10-22T19:11:17.000+0000
Examples of the suggested changes
Posted by Alex Kirsch (alex.kirsch) on 2006-10-27T08:48:42.000+0000
You got my vote,
Seems like a nice addition to the interface.
Posted by Bill Karwin (bkarwin) on 2006-11-13T15:30:37.000+0000
Changing fix version to 0.6.0.
Posted by Christian Szardenings (bitrockers) on 2006-11-30T13:55:42.000+0000
I highly recommend this change, because in production enviroments it's often needed set individual lifetimes. With memcache or APC as backend, there's nothing more to do, because APC/memcache function support lifetime/ttl options, if you apply the patch by Lee.
When using the File backend, you also should improve the _clean method (Zend_Cache_Backend_File) in a way that it cleans the cache records (files) in regard to the specified lifetime. You could do this by either storing the lifetime in the file, or adding the lifetime to the filename.
I would suggest the latter option, because you wouldn't have to open each file for finding the desired lifetime. Example filename could be cache_$id_$lifeTime.
Posted by Christian Szardenings (bitrockers) on 2006-11-30T14:14:59.000+0000
Sorry, I have to cancel my last suggestion. Storing the lifetime in the cache file is a bad idea, because the Cache wouldn't know the exact filename (so it would become difficult to open it fast enough). :-)
So there're two other options (if i'm right this time): a) store lifetime in the file b) store lifetimes of cache in extra file
Choosing a) would cause the clean process to last a bit longer (opening the files). The advantage would be, that the load-method also could delete expired records.
Option b) would allow faster deletion by the the _clean method, but causes a little overhead when creating the cache file.
Posted by Matthew Ratzloff (mratzloff) on 2006-11-30T17:53:26.000+0000
I strongly agree with this. A global lifetime on its own is insufficient for the kinds of things I do, and creating multiple Zend_Cache objects seems superfluous.
To elaborate on Christian's comment, your two options could be:
For those reasons, I'm in favor of embedding the lifetime in the cached file itself.
As far as usage, I would prefer the ability to do something like the following:
A global lifetime could still be set, but it would only be a default value. Posted by Lee Saferite (lsaferite) on 2006-11-30T19:02:37.000+0000 Even though I forgot to make a patch file for or even mention it, this should of course apply to the frontend as well. Posted by Fabien MARTY (fab) on 2007-02-08T15:34:11.000+0000 this feature is now in SVN version (you can use a specfic lifetime per cache (fourth argument of the save() method)
Have you found an issue?
See the Overview section for more details.