Changeset 7420 for lang/php

Show
Ignore:
Timestamp:
03/03/08 22:05:59 (5 years ago)
Author:
takuya
Message:

lang/php/Cache: キャッシュの有効期限周りを修正

Location:
lang/php/Cache/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • lang/php/Cache/trunk/Cache/Handler.php

    r6899 r7420  
    154154        //キャッシュをドライバから読み出す、Templateメソッド 
    155155        protected function readCache($id) { 
    156                 if( $this->temp["id"] && $this->temp["id"] === $id ) { 
     156                if( isset($this->temp["id"]) && $this->temp["id"] === $id ) { 
    157157                        $data = $this->temp; 
    158158                }else { 
     
    165165                        $this->temp=$data; 
    166166                } 
     167                var_dump($this->temp); 
    167168                return $data["content"]; 
    168169        } 
  • lang/php/Cache/trunk/Cache/Handler/Resource/File.php

    r7154 r7420  
    7171    * @access public 
    7272    */ 
    73     public function __construct( $ini ) 
     73    public function __construct( $ini=array() ) 
    7474    { 
    7575        foreach ( $ini as $key => $val ) { 
     
    594594            $array[$line[0]] = $line[1]; 
    595595        } 
    596         return $array; 
     596        return sizeof($array)!=0 ? $array: null ; 
    597597    } 
    598598    /**  
  • lang/php/Cache/trunk/Cache/Utils.php

    r6956 r7420  
    1616//require_once "Cache/Handler.php"; 
    1717//require_once "Cache/Handler/Resource/File.php"; 
    18  
     18//TODO:File.php以外も使えるようにする。 
    1919function cache_get_contents($id, $path=null){ 
    2020        //モジュールを確認 
     
    2424        $path = $path ? $path : $_SERVER["TMP"]; 
    2525        $handler = new Cache_Handler(); 
    26         $handler->setResource(new Cache_Handler_Resource_File($path)); 
     26        $handler->setResource(new Cache_Handler_Resource_File( array("path"=>$path))); 
    2727        return $handler->getCache($id);; 
    2828} 
  • lang/php/Cache/trunk/tests/Cache_Test.php

    r6957 r7420  
    1212require_once ("Cache/Utils.php"); 
    1313 
    14  
    15 cache_put_contents( "test", "test1" ); 
    16  
     14$id = "test_id_01"; 
     15cache_put_contents( $id, "test1", "c:/cache" ); 
     16$cache = cache_get_contents($id, "c:/cache");