cvs: pear /Cache_Lite Lite.php
| From: | Fabien MARTY | Date: | Sat, 14 May 2005 10:07:40 +0000 |
| Subject: | cvs: pear /Cache_Lite Lite.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-31851@lists.php.net to get a copy of this message | ||
fab Sat May 14 06:07:40 2005 EDT
Modified files:
/pear/Cache_Lite Lite.php
Log:
Request #4261 : umask for hashed directory structures is now an option of the constructor
http://cvs.php.net/diff.php/pear/Cache_Lite/Lite.php?r1=1.28&r2=1.29&ty=u
Index: pear/Cache_Lite/Lite.php
diff -u pear/Cache_Lite/Lite.php:1.28 pear/Cache_Lite/Lite.php:1.29
--- pear/Cache_Lite/Lite.php:1.28 Sat May 14 05:52:31 2005
+++ pear/Cache_Lite/Lite.php Sat May 14 06:07:40 2005
@@ -19,7 +19,7 @@
*
* @package Cache_Lite
* @category Caching
-* @version $Id: Lite.php,v 1.28 2005/05/14 09:52:31 fab Exp $
+* @version $Id: Lite.php,v 1.29 2005/05/14 10:07:40 fab Exp $
* @author Fabien MARTY <fab@php.net>
*/
@@ -217,11 +217,23 @@
/**
* Nested directory level
*
+ * Set the hashed directory structure level. 0 means "no hashed directory
+ * structure", 1 means "one level of directory", 2 means "two
levels"...
+ * This option can speed up Cache_Lite only when you have many thousands of
+ * cache file. Only specific benchs can help you to choose the perfect value
+ * for you. Maybe, 1 or 2 is a good start.
*
* @var int $_hashedDirectoryLevel
*/
var $_hashedDirectoryLevel = 0;
+ /**
+ * Umask for hashed directory structure
+ *
+ * @var int $_hashedDirectoryUmask
+ */
+ var $_hashedDirectoryUmask = 0700;
+
// --- Public methods ---
/**
@@ -244,6 +256,7 @@
* 'automaticSerialization' => enable / disable automatic serialization
(boolean)
* 'automaticCleaningFactor' => distable / tune automatic cleaning process
(int)
* 'hashedDirectoryLevel' => level of the hashed directory system (int)
+ * 'hashedDirectoryUmask' => umask for hashed directory structure (int)
* );
*
* @param array $options options
@@ -251,7 +264,7 @@
*/
function Cache_Lite($options = array(NULL))
{
- $availableOptions = array('hashedDirectoryLevel',
'automaticCleaningFactor', 'automaticSerialization',
'fileNameProtection', 'memoryCaching', 'onlyMemoryCaching',
'memoryCachingLimit', 'cacheDir', 'caching', 'lifeTime',
'fileLocking', 'writeControl', 'readControl',
'readControlType', 'pearErrorMode');
+ $availableOptions = array('hashedDirectoryUmask',
'hashedDirectoryLevel', 'automaticCleaningFactor',
'automaticSerialization', 'fileNameProtection', 'memoryCaching',
'onlyMemoryCaching', 'memoryCachingLimit', 'cacheDir',
'caching', 'lifeTime', 'fileLocking', 'writeControl',
'readControl', 'readControlType', 'pearErrorMode');
foreach($options as $key => $value) {
if(in_array($key, $availableOptions)) {
$property = '_'.$key;
@@ -681,7 +694,7 @@
$root = $this->_cacheDir;
for ($i=0 ; $i<$this->_hashedDirectoryLevel ; $i++) {
$root = $root . 'cache_' . substr($hash, 0, $i + 1) .
'/';
- @mkdir($root, umask());
+ @mkdir($root, $this->_hashedDirectoryUmask);
}
$try = 2;
} else {