This repository has been archived on 2025-06-10. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
server/onyx/require/cache.php
2013-10-09 15:40:23 +02:00

35 lines
No EOL
1 KiB
PHP

<?php
class Cache
{
static function set($id,$var)
{
$file = '<?php $cache = '.var_export($var,TRUE).'; ?>';
file_put_contents(ONYX.'cache/'.md5($id).'.cache.php',$file) or trigger_error('dossier cache inaccessible en écriture.',E_USER_ERROR);
}
static function read($id)
{
if(!is_readable(ONYX.'cache/'.md5($id).'.cache.php')) return FALSE;
include(ONYX.'cache/'.md5($id).'.cache.php');
if(!$cache) return FALSE;
return $cache;
}
static function del($id)
{
if(!is_file(ONYX.'cache/'.md5($id).'.cache.php')) return FALSE;
return unlink(ONYX.'cache/'.md5($id).'.cache.php');
}
static function flush()
{
foreach(glob(ONYX.'cache/*.cache.php') as $file) unlink($file);
}
}
?>