cvs: pear /Cache_Lite Lite.php
| From: | Fabien MARTY | Date: | Sat, 01 Feb 2003 20:05:40 +0000 |
| Subject: | cvs: pear /Cache_Lite Lite.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-8651@lists.php.net to get a copy of this message | ||
fab Sat Feb 1 15:05:40 2003 EDT
Modified files:
/pear/Cache_Lite Lite.php
Log:
Add of a file name protection option (can be faster if set to off) (thanks to Brian Webb
<bwebb9@yahoo.com> for the idea)
Index: pear/Cache_Lite/Lite.php
diff -u pear/Cache_Lite/Lite.php:1.8 pear/Cache_Lite/Lite.php:1.9
--- pear/Cache_Lite/Lite.php:1.8 Sun Jan 26 07:49:22 2003
+++ pear/Cache_Lite/Lite.php Sat Feb 1 15:05:39 2003
@@ -15,7 +15,7 @@
*
* @package Cache_Lite
* @category Caching
-* @version $Id: Lite.php,v 1.8 2003/01/26 12:49:22 fab Exp $
+* @version $Id: Lite.php,v 1.9 2003/02/01 20:05:39 fab Exp $
* @author Fabien MARTY <fab@php.net>
*/
@@ -166,6 +166,18 @@
* @var int $memoryCachingLimit
*/
var $_memoryCachingLimit = 1000;
+
+ /**
+ * File Name protection
+ *
+ * if set to true, you can use any cache id or group name
+ * if set to false, it can be faster but cache ids and group names
+ * will be used directly in cache file names so be carefull with
+ * special characters...
+ *
+ * @var boolean $fileNameProtection
+ */
+ var $_fileNameProtection = true;
// --- Public methods ---
@@ -192,7 +204,7 @@
*/
function Cache_Lite($options = array(NULL))
{
- $availableOptions =
'{memoryCaching}{onlyMemoryCaching}{memoryCachingLimit}{cacheDir}{caching}{lifeTime}{fileLocking}{writeControl}{readControl}{readControlType}{pearErrorMode}';
+ $availableOptions =
'{fileNameProtection}{memoryCaching}{onlyMemoryCaching}{memoryCachingLimit}{cacheDir}{caching}{lifeTime}{fileLocking}{writeControl}{readControl}{readControlType}{pearErrorMode}';
while (list($key, $value) = each($options)) {
if (strpos('>'.$availableOptions, '{'.$key.'}')) {
$property = '_'.$key;
@@ -309,7 +321,11 @@
*/
function clean($group = false)
{
- $motif = ($group) ? 'cache_'.md5($group).'_' : 'cache_';
+ if ($this->_fileNameProtection) {
+ $motif = ($group) ? 'cache_'.md5($group).'_' : 'cache_';
+ } else {
+ $motif = ($group) ? 'cache_'.$group.'_' : 'cache_';
+ }
if ($this->_memoryCaching) {
while (list($key, $value) = each($this->_memoryCaching)) {
if (strpos($key, $motif, 0)) {
@@ -440,7 +456,11 @@
*/
function _setFileName($id, $group)
{
- $this->_file =
($this->_cacheDir.'cache_'.md5($group).'_'.md5($id));
+ if ($this->_fileNameProtection) {
+ $this->_file =
($this->_cacheDir.'cache_'.md5($group).'_'.md5($id));
+ } else {
+ $this->_file = $this->_cacheDir.'cache_'.$group.'_'.$id;
+ }
}
/**