Changeset 1107

Show
Ignore:
Timestamp:
12/04/07 13:38:45 (9 months ago)
Author:
mikey
Message:

added net::stubbles::util::cache::stubCacheContainer::getStoreTime()
BC-Break: renamed net::stubbles::util::cache::stubCacheContainer::getCacheTime() to net::stubbles::util::cache::stubCacheContainer::getLifeTime()

Files:

Legend:

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

    r742 r1107  
    8080     * @return  int 
    8181     */ 
    82     public function getCacheTime($key); 
     82    public function getLifeTime($key); 
     83 
     84    /** 
     85     * returns the timestamp when data associated with $key is cached 
     86     * 
     87     * @param   string  $key 
     88     * @return  int 
     89     */ 
     90    public function getStoreTime($key); 
    8391 
    8492    /** 
  • trunk/src/main/php/net/stubbles/util/cache/stubDefaultCacheStrategy.php

    r742 r1107  
    8383    public function isExpired(stubCacheContainer $container, $key) 
    8484    { 
    85         return ($container->getCacheTime($key) > $this->ttl); 
     85        return ($container->getLifeTime($key) > $this->ttl); 
    8686    } 
    8787 
  • trunk/src/main/php/net/stubbles/util/cache/stubFileCacheContainer.php

    r1064 r1107  
    112112     * @return  int 
    113113     */ 
    114     public function getCacheTime($key) 
     114    public function getLifeTime($key) 
    115115    { 
    116116        if ($this->doHas($key) == true) { 
    117117            return (time() - filemtime($this->cacheDirectory . DIRECTORY_SEPARATOR . $this->escapeKey($key) . '.cache')); 
     118        } 
     119         
     120        return 0; 
     121    } 
     122 
     123    /** 
     124     * returns the timestamp when data associated with $key is cached 
     125     * 
     126     * @param   string  $key 
     127     * @return  int 
     128     */ 
     129    public function getStoreTime($key) 
     130    { 
     131        if ($this->doHas($key) == true) { 
     132            return filemtime($this->cacheDirectory . DIRECTORY_SEPARATOR . $this->escapeKey($key) . '.cache'); 
    118133        } 
    119134         
  • trunk/src/test/php/net/stubbles/util/cache/stubAbstractCacheContainerTestCase.php

    r742 r1107  
    3333    } 
    3434 
    35     public function getCacheTime($key) 
     35    public function getLifeTime($key) 
    3636    { 
    3737        if ($this->doHas($key) == true) { 
     
    4242    } 
    4343 
     44    public function getStoreTime($key) 
     45    { 
     46        if ($this->doHas($key) == true) { 
     47            return $this->data[$key]['time']; 
     48        } 
     49         
     50        return 0; 
     51    } 
     52     
    4453    protected function doGetSize($key) 
    4554    { 
  • trunk/src/test/php/net/stubbles/util/cache/stubDefaultCacheStrategyTestCase.php

    r741 r1107  
    6161        $defaultCacheStrategy = new stubDefaultCacheStrategy(10, 2, 0); 
    6262        $mockContainer        = new MockstubCacheContainer(); 
    63         $mockContainer->setReturnValueAt(0, 'getCacheTime', 9); 
    64         $mockContainer->setReturnValueAt(1, 'getCacheTime', 10); 
    65         $mockContainer->setReturnValueAt(2, 'getCacheTime', 11); 
     63        $mockContainer->setReturnValueAt(0, 'getLifeTime', 9); 
     64        $mockContainer->setReturnValueAt(1, 'getLifeTime', 10); 
     65        $mockContainer->setReturnValueAt(2, 'getLifeTime', 11); 
    6666         
    6767        $this->assertFalse($defaultCacheStrategy->isExpired($mockContainer, 'a'));