Reply to Getting from cache method from class
Getting from cache method from class Posted by Alexander Shatalov PHP public static function get($name, $incTime=3600, $use_file=false, $echo = false, $ob_func = false) { if ($use_file) { $name = File::fixFilename($name); if (($file = FTP_DIR_CACHE.$name.'.'.self::$cache_ext) && file_exists($file) && (is_numeric(File::Ext($name)) || (!$incTime || ($incTime>0 && filemtime($file) > (time() - $incTime))))) { if ($echo) { if ($ob_func) ob_start($ob_func); readfile($file); echo '<!-- cached '.$file.'-->'; if ($ob_func) ob_end_flush(); return true; } else { return strexp(file_get_contents($file)); } } return false; } else { return strexp(DB::row('SELECT `data` FROM `'.DB::getPrefix().'cache` WHERE `name`='.escape($name).($incTime? 'AND saved > '.(time() - $incTime):''),'data')); } } |