Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.8.3

Request #6290 non-specific automaticCleaningFactor
Submitted: 2005-12-19 17:29 UTC
From: kenrick at thebusypixel dot com Assigned: fab
Status: Closed Package: Cache_Lite
PHP Version: 4.3.11 OS: linux
Roadmaps: (Not assigned)    
Subscription  
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes. If this is not your bug, you can add a comment by following this link. If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
2006-02-05 19:54 UTC
Package:
Bug Type:
Summary:
From: kenrick at thebusypixel dot com
New email:
PHP Version: Package Version: OS:

 

 [2005-12-19 17:29 UTC] kenrick at thebusypixel dot com
Description: ------------ ver 1.62 of Cache_Lite, but this is present I think in most versions. automaticCleaningFactor - this is not immediatley apparent that it pertains to ALL created cache files. If this is specified in multiple instances of Cache_Lite, you will find your caches randomly cleaned, because it just wipes out all files, not just the file you are specifically caching. Im not sure if this is the desired behavoir, but I had to find out that this is what it does the hard way. Test script: --------------- require_once('Cache/Lite.php'); $id = 'articles/index'; $options = array( 'cacheDir'=>CACHE_PATH, 'lifeTime'=>3600, 'automaticCleaningFactor'=>20 ); $Cache_Lite = new Cache_Lite($options); if ( $page = $Cache_Lite->get($id) ) { return $page; } else { $page = 'some data'; $Cache_Lite->save($page); return $page } Expected result: ---------------- I expect that Cache Lite would ONLY clean the requested cache, but instead it cleans all in the CACHE_PATH dir Actual result: -------------- haha no files. ;)

Comments

 [2006-02-02 23:02 UTC] pao at caramail dot com
Well that's the result I was expecting from reading the doc. It's some sort of a garbage collector.
 [2006-02-04 13:02 UTC] fab at php dot net
Sure but I understand his point of view. I think it can be usefull to get a garbage collector ___only___ on a specifice cache id. But I don't accept this as a bug so we have to found a way to propose this feature without breaking the API.
 [2006-02-04 20:07 UTC] fab at php dot net
After trying to code this, I have a problem :) IMHO, the automaticCleaning for a specific cache file has no interest at all ! The cleaning is done when a cache is written on disk. As the cache filename doesn't change, the cache file will never be cleaned because the cache was just written !!! kenrick ?
 [2006-02-05 19:54 UTC] kenrick at thebusypixel dot com
Well in light of all the comments, maybe its best to put in a best practices sort of thing. This is how I ran into trouble: Create multiple instance of the Cache_Lite object. Give them all the same lifetime except for one, give that a different lifetime. Put all the caches in the same directory. If autoclean is specified on of the instance with the different lifetime, your other cache files may or may not be there, possibly creating too many cache writes and poor performance. Best practice then would appear to be that you create directories for each of your caches if you want to be using this autocleanfactor. True the filename never changes, and is overwritten on write. Where I first observed this problem is that I am caching some pages that are dynamically generated, that will rarely change after once being generated (an article lets say) kept in the same dir as some cached content that has a lifetime of 1 hour, and other caches that have a lifetime as small as 15 minutes. I had autoclean on a couple of instances and my cache performance was awful since it kept being wiped (using the random 1 times on x cache write). Ill close this and just hope for a best practice example for large sites.