快捷搜索:   服务器  安全  linux 安全  MYSQL  dedecms

一个强大的PHP缓存类(10)


                fopen($this->cache_path.$this->application_file, 'w');
            }
             
        }
        
        // write application data to file
        private function APP_write(){
            if ($this->application_write){
                $data = serialize($this->application);
                $file = fopen($this->cache_path.$this->application_file, 'w');
                if ($file){
                    $this->addLog('writting APP file: '.$this->cache_path.$this->application_file);
                    fwrite($file, $data);
                    fclose($file);
                }
            }
        }
        
        //returns the value form APP cache or stores it
        private function APP($var,$value=''){
            if ($value!=''){//wants to write
                
                if (is_array($this->application)){
                    if ( array_key_exists(md5($var), $this->application) ){//exist the value in the APP
                        $write=false;//we don't need to wirte
                        if ($this->application[md5($var)]!=$value)$write=true;//but exists and is different then we write
                    }
                    else $write=true;//not set we write!
                }
                else $write=false;
    
                if ($write){
                    $this->addLog('writting APP key:'.$var);
                    $this->application[md5($var)]=$value;
                    $this->application_write=true;//says that we have changes to later save the APP
                }
            }
            else {//reading
                if ( !is_array($this->application) || ! array_key_exists(md5($var), $this->application) ){
                    $this->addLog('nothing found for APP key:'.$var);
                    return null;//nothing found not in array
顶(0)
踩(0)

您可能还会对下面的文章感兴趣:

最新评论