示例#1
0
文件: Cache.php 项目: hovenko/Madcow
<?php

define('DEFAULT_CACHE_DIR', DF_Web::path_to('cache'));
class DF_Web_Model_Cache extends DF_Web_Model
{
    private $_cache = NULL;
    protected $config = array('cache_class' => 'DF_Web_Cache_Lite', 'cache_config' => array('lifeTime' => 300, 'cacheDir' => DEFAULT_CACHE_DIR));
    public function get_cache()
    {
        return $this->_cache;
    }
    public function initialize($c)
    {
        $class = $this->config['cache_class'];
        $config = $this->config['cache_config'];
        $file = preg_replace('|_|', '/', $class);
        require_once "{$file}.php";
        $this->_cache = new $class($config);
    }
}
示例#2
0
<?php

define('DEFAULT_DATA_DIR', DF_Web::path_to('data'));
class DF_Web_Model_DataDir extends DF_Web_Model
{
    private $_cache = NULL;
    protected $config = array('dataDir' => DEFAULT_DATA_DIR);
    public function getDataDir()
    {
        return $this->config['dataDir'];
    }
    public function getFileContent($name)
    {
        $dir = $this->getDataDir();
        $content = file_get_contents($dir . $name);
        return $content;
    }
    public function putFileContent($name, $content)
    {
        $dir = $this->getDataDir();
        file_put_contents($dir . $file, $content);
    }
}