Changeset 23600 for branches/version-2_13-dev/data/module/Cache/Lite.php
- Timestamp:
- 2014/08/22 18:31:39 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_13-dev/data/module/Cache/Lite.php
r22587 r23600 248 248 */ 249 249 var $_errorHandlingAPIBreak = false; 250 251 var $_hashedDirectoryGroup = NULL; 252 253 var $_cacheFileMode = NULL; 254 255 var $_cacheFileGroup = NULL; 250 256 251 257 // --- Public methods --- … … 273 279 * 'hashedDirectoryUmask' => umask for hashed directory structure (int), 274 280 * 'errorHandlingAPIBreak' => API break for better error handling ? (boolean) 281 * 'hashedDirectoryGroup' => group of hashed directory structure (int | string) (see function chgrp) 282 * 'cacheFileMode' => filesystem mode of newly created cache files (int) 283 * 'cacheFileGroup' => group of newly created cache files (int | string) (see function chgrp) 275 284 * ); 276 285 * … … 307 316 function setOption($name, $value) 308 317 { 309 $availableOptions = array('errorHandlingAPIBreak', 'hashedDirectoryUmask', 'hashedDirectoryLevel', 'automaticCleaningFactor', 'automaticSerialization', 'fileNameProtection', 'memoryCaching', 'onlyMemoryCaching', 'memoryCachingLimit', 'cacheDir', 'caching', 'lifeTime', 'fileLocking', 'writeControl', 'readControl', 'readControlType', 'pearErrorMode' );318 $availableOptions = array('errorHandlingAPIBreak', 'hashedDirectoryUmask', 'hashedDirectoryLevel', 'automaticCleaningFactor', 'automaticSerialization', 'fileNameProtection', 'memoryCaching', 'onlyMemoryCaching', 'memoryCachingLimit', 'cacheDir', 'caching', 'lifeTime', 'fileLocking', 'writeControl', 'readControl', 'readControlType', 'pearErrorMode', 'hashedDirectoryGroup', 'cacheFileMode', 'cacheFileGroup'); 310 319 if (in_array($name, $availableOptions)) { 311 320 $property = '_'.$name; … … 666 675 return $result; 667 676 } 668 677 678 /** 679 * Touch the cache file while are recreating it to avoid 680 * launch this task more then once when necessary 681 * When the cache recreated and Added in Cache Memory 682 * @return void 683 * @access private 684 */ 685 function _touchCacheFile(){ 686 if (file_exists($this->_file)) { 687 @touch($this->_file); 688 } 689 } 669 690 /** 670 691 * Add some date in the memory caching array … … 675 696 function _memoryCacheAdd($data) 676 697 { 698 $this->_touchCacheFile(); 677 699 $this->_memoryCachingArray[$this->_file] = $data; 678 700 if ($this->_memoryCachingCounter >= $this->_memoryCachingLimit) { … … 776 798 $root = $root . 'cache_' . substr($hash, 0, $i + 1) . '/'; 777 799 if (!(@is_dir($root))) { 778 @mkdir($root, $this->_hashedDirectoryUmask); 800 if (@mkdir($root)) 801 { 802 @chmod($root, $this->_hashedDirectoryUmask); 803 if (! is_null($this->_hashedDirectoryGroup)) 804 @chgrp($root, $this->_hashedDirectoryGroup); 805 } 779 806 } 780 807 } 781 808 } 809 // if both _cacheFileMode and _cacheFileGroup is null, then we don't need to call 810 // file_exists (see below: if ($is_newfile) ...) 811 $is_newfile = (! is_null($this->_cacheFileMode) || !is_null($this->_cacheFileGroup)) 812 && ! @file_exists($this->_file); 782 813 $fp = @fopen($this->_file, "wb"); 783 814 if ($fp) { 784 815 if ($this->_fileLocking) @flock($fp, LOCK_EX); 816 if ($is_newfile) 817 { 818 if (! is_null($this->_cacheFileMode)) 819 @chmod($this->_file, $this->_cacheFileMode); 820 if (! is_null($this->_cacheFileGroup)) 821 @chgrp($this->_file, $this->_cacheFileGroup); 822 } 785 823 if ($this->_readControl) { 786 824 @fwrite($fp, $this->_hash($data, $this->_readControlType), 32);
Note: See TracChangeset
for help on using the changeset viewer.