| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Limb PHP Framework 4 * 5 * @link http://limb-project.com 6 * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com) 7 * @license LGPL http://www.gnu.org/copyleft/lesser.html 8 */ 9 lmb_require('limb/fs/src/lmbFs.class.php'); 10 11 /** 12 * class lmbFullPageCacheWriter. 13 * 14 * @package web_cache 15 * @version $Id: lmbFullPageCacheWriter.class.php 5945 2007-06-06 08:31:43Z pachanga $ 16 */ 17 class lmbFullPageCacheWriter 18 { 19 protected $storage_dir; 20 protected $cache_file = 'cache.html'; 21 22 function __construct($dir) 23 { 24 $this->storage_dir = $dir; 25 } 26 27 function setStorageDirectory($dir) 28 { 29 $this->storage_dir = $dir; 30 } 31 32 function getCacheFile() 33 { 34 return $this->cache_file; 35 } 36 37 function setCacheFile($file) 38 { 39 $this->cache_file = $file; 40 } 41 42 function _getFilePath($cache) 43 { 44 return $this->storage_dir . '/' . $cache . '/' . $this->cache_file; 45 } 46 47 function flush($cache = null) 48 { 49 if(!$cache) 50 return $this->flushAll(); 51 52 if(file_exists($file = $this->_getFilePath($cache))) 53 { 54 unlink($file); 55 return true; 56 } 57 58 return false; 59 } 60 61 function flushAll() 62 { 63 return lmbFs :: rm($this->storage_dir); 64 } 65 66 function getCacheSize() 67 { 68 $files = lmbFs :: findRecursive($this->storage_dir, 'f'); 69 70 $size = 0; 71 foreach($files as $file) 72 $size += filesize($file); 73 74 return $size; 75 } 76 77 function save($cache, $contents) 78 { 79 $file = $this->_getFilePath($cache); 80 $dir = dirname($file); 81 82 //cache conflict 83 if(basename($dir) == $this->cache_file) 84 return false; 85 86 lmbFs :: mkdir($dir); 87 lmbFs :: safeWrite($file, $contents); 88 } 89 90 function get($cache) 91 { 92 if(file_exists($file = $this->_getFilePath($cache))) 93 return file_get_contents($file); 94 else 95 return false; 96 } 97 } 98 99 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Oct 7 05:02:03 2008 | Cross-referenced by PHPXref 0.7 |