caching - how to use php stream to block DWOO compile the cache files everytime? -
i code thread talking blocking dwoo using php streams can't understand how use code. can tell me how use it?
recent problem:
i've got serious problem storage on web hosting because of lot of cache files created on @ cache/dwoo/compiled folder. developed website using codeigniter framework. want disable feature (auto created cache files @ cache/dwoo/compiled folder), because using lot of space on storage.
this code:
include 'lib/dwooautoload.php'; include 'dwoo/compiler.php'; $dwoo = new dwoo(); stream_wrapper_register('dwoomem', 'dwoo_template_memory_streamwrapper'); $dwoo->addresource('memory', 'dwoo_template_memory'); $tpl = new dwoo_template_memory('test.html'); $dwoo->output($tpl, array('foo'=>'foo', 'bar'=>'bar')); class dwoo_template_memory extends dwoo_template_file { protected $chmod = null; public function getcompiledfilename(dwoo $dwoo) { // no compile id provided, set default if ($this->compileid===null) { $this->compileid = $this->getresourceidentifier(); } return 'dwoomem://'.$this->compileid; } protected function makedirectory($path) { } } class dwoo_template_memory_streamwrapper { protected static $streams = array(); function stream_open($path, $mode, $options, &$opened_path) { if (!isset(self::$streams[$path])) { if(!($mem = fopen('php://memory', 'w+'))) { return false; } self::$streams[$path] = $mem; } $this->res = self::$streams[$path]; $this->stream_seek(0); return true; } function stream_read($count) { return fread($this->res, $count); } function stream_write($data) { return fwrite($this->res, $data); } function stream_eof() { return feof($this->res); } function stream_seek($offset, $whence=seek_set) { return fseek($this->res, $offset, $whence); } function stream_stat() { return fstat($this->res); } public static function url_stat($path, $flags) { return array(); } }
Comments
Post a Comment