Changeset 739
- Timestamp:
- 06/20/07 15:09:01 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/util/cache/stubDefaultCacheStrategy.php
r738 r739 14 14 * @subpackage util_cache 15 15 */ 16 class stub CacheStrategy extends stubBaseObject implements stubCacheStrategy16 class stubDefaultCacheStrategy extends stubBaseObject implements stubCacheStrategy 17 17 { 18 18 /** trunk/src/main/php/net/stubbles/util/cache/stubFileCacheContainer.php
r738 r739 30 30 */ 31 31 protected $keys = null; 32 /** 33 * size of cache entries 34 * 35 * @var array<string,int> 36 */ 37 protected $size = null; 32 38 33 39 /** … … 55 61 if (null !== $this->keys) { 56 62 $this->keys[$key] = $key; 63 } 64 65 if (null !== $this->size) { 66 $this->size[$key] = $bytes; 57 67 } 58 68 … … 117 127 public function getUsedSpace() 118 128 { 119 $usedSpace = 0; 120 foreach ($this->getKeys() as $key) { 121 $usedSpace += filesize($this->cacheDirectory . '/' . $key . '.cache'); 129 if (null === $this->size) { 130 $this->size = array(); 131 $dirIt = new DirectoryIterator($this->cacheDirectory); 132 foreach ($dirIt as $file) { 133 if ($file->isDot() == true || $file->isDir() == true) { 134 continue; 135 } 136 137 $key = str_replace('.cache', '', $file->getFilename()); 138 $this->size[$key] = filesize($this->cacheDirectory . '/' . $key . '.cache'); 139 } 122 140 } 123 141 124 return $usedSpace;142 return array_sum($this->size); 125 143 } 126 144 … … 166 184 if ($this->strategy->isExpired($this, $key) == true) { 167 185 unlink($this->cacheDirectory . '/' . $key . '.cache'); 186 if (null !== $this->size) { 187 unset($this->size[$key]); 188 } 168 189 } 169 190 }
