Changeset 739

Show
Ignore:
Timestamp:
06/20/07 15:09:01 (1 year ago)
Author:
mikey
Message:

bugfixes for cache classes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/util/cache/stubDefaultCacheStrategy.php

    r738 r739  
    1414 * @subpackage  util_cache 
    1515 */ 
    16 class stubCacheStrategy extends stubBaseObject implements stubCacheStrategy 
     16class stubDefaultCacheStrategy extends stubBaseObject implements stubCacheStrategy 
    1717{ 
    1818    /** 
  • trunk/src/main/php/net/stubbles/util/cache/stubFileCacheContainer.php

    r738 r739  
    3030     */ 
    3131    protected $keys           = null; 
     32    /** 
     33     * size of cache entries 
     34     * 
     35     * @var  array<string,int> 
     36     */ 
     37    protected $size           = null; 
    3238 
    3339    /** 
     
    5561        if (null !== $this->keys) { 
    5662            $this->keys[$key] = $key; 
     63        } 
     64         
     65        if (null !== $this->size) { 
     66            $this->size[$key] = $bytes; 
    5767        } 
    5868         
     
    117127    public function getUsedSpace() 
    118128    { 
    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            } 
    122140        } 
    123141         
    124         return $usedSpace
     142        return array_sum($this->size)
    125143    } 
    126144 
     
    166184            if ($this->strategy->isExpired($this, $key) == true) { 
    167185                unlink($this->cacheDirectory . '/' . $key . '.cache'); 
     186                if (null !== $this->size) { 
     187                    unset($this->size[$key]); 
     188                } 
    168189            } 
    169190        }