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

Request #7736 Ability to specify CacheLite group for CacheLite Decorator
Submitted: 2006-05-28 00:38 UTC Modified: 2006-05-28 10:06 UTC
From: ajt Assigned: quipo
Status: Closed Package: Translation2 (version CVS)
PHP Version: Irrelevant OS: n/a
Roadmaps: (Not assigned)    
Subscription  


 [2006-05-28 00:38 UTC] ajt (AJ Tarachanowicz II)
Description: ------------ This patch allows you to specify a default group to be used with the CacheLite Decorator. The purpose is to allow Translation2 CacheLite files and non-Translation2 CacheLite files to reside in the same directory. Currently if you call Translation2_Admin::cleanCache() it removes all CacheLite files in the current direcotry. This patch makes it so that it only removes the Translation2 CacheLite files. Leaving the non-Translation2 CacheLite files alone. Test script: --------------- Index: Admin.php =================================================================== RCS file: /repository/pear/Translation2/Admin.php,v retrieving revision 1.18 diff -u -r1.18 Admin.php --- Admin.php 13 Oct 2005 06:41:39 -0000 1.18 +++ Admin.php 28 May 2006 05:32:40 -0000 @@ -130,7 +130,7 @@ function _setDefaultOptions() { $this->options['autoCleanCache'] = false; - $this->options['cacheOptions'] = array(); + $this->options['cacheOptions'] = array('defaultGroup' => 'Translation2'); parent::_setDefaultOptions(); } @@ -328,7 +328,7 @@ require_once 'Cache/Lite/Function.php'; $cacheLiteFunction = new Cache_Lite_Function($this->options['cacheOptions']); } - $cacheLiteFunction->clean(); + $cacheLiteFunction->clean($this->options['cacheOptions']['defaultGroup']); } // }}} Index: Decorator/CacheLiteFunction.php =================================================================== RCS file: /repository/pear/Translation2/Decorator/CacheLiteFunction.php,v retrieving revision 1.13 diff -u -r1.13 CacheLiteFunction.php --- Decorator/CacheLiteFunction.php 8 Sep 2005 22:29:10 -0000 1.13 +++ Decorator/CacheLiteFunction.php 28 May 2006 05:32:40 -0000 @@ -93,8 +93,8 @@ var $cacheDir = '/tmp/'; /** - * Directory where to put the cache files - * (make sure to add a trailing slash) + * Enable / disable fileLocking. Can avoid cache corruption under bad + * circumstances. * @var string $cacheDir * @access private */ @@ -115,6 +115,12 @@ */ var $cleaningFrequency = 0; + /** + * Name of default cache group. + * @var string $defaultGroup + */ + var $defaultGroup = 'Translation2'; + // }}} // {{{ _prepare() @@ -132,6 +138,7 @@ 'cacheDir' => $this->cacheDir, 'lifeTime' => $this->lifeTime, 'fileLocking' => $this->fileLocking, + 'defaultGroup' => $this->defaultGroup, ); $this->cacheLiteFunction = new Cache_Lite_Function($cache_options); } @@ -309,7 +316,7 @@ { if ($this->cleaningFrequency > 0) { if (mt_rand(1, $this->cleaningFrequency) == 1) { - $this->cacheLiteFunction->clean(); + $this->cacheLiteFunction->clean($this->defaultGroup); } } }

Comments

 [2006-05-28 10:06 UTC] quipo (Lorenzo Alberton)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.