Cache_Graphics garbage collection

From: Date: Tue, 13 Sep 2005 21:28:53 +0000
Subject: Cache_Graphics garbage collection
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-20951@lists.php.net to get a copy of this message
I'm using Cache_Graphics 1.5.4 to cache dynamically resized graphics: ---------- $imgcache = new Cache_Graphics(); $imgcache->setCacheDir("/var/cache/www"); $imgcache->setCacheURL("http://images.hirners.com/cache"); function resize_img() { // ... if ($obj_link = $imgcache->getImageLink($obj_id, "jpg")) return $obj_link[1]; else { ... $obj = $imgcache->cacheImageLink($obj_id, $img, "jpg"); return $obj[1]; } ---------- This works perfectly, with one exception: the cache is never cleared. The images remain in the cache forever and are not removed after not being used for 86400 seconds. I found out that Cache_Graphics doesn't provide a destructor and so the Cache::_Cache destructor is not called, too. So I appended "$imgcache->garbageCollection(true)" (true because I wanted to see if garbage collection works) to my image-generating code. I was suprised that the forced garbage collection removed ALL images, even the new ones which were not expired. Is it possible to do correct garbage collection with Cache_Graphics? I know that I could remove expired images with a simple command from cron, but I want to use the garbage collection, if possible. -- Richard Hirner <richard@hirner.at> Jabber-ID: sssr@jabber.adaxas.net

« previous php.pear.general (#20951) next »