<?php
/* Please see the README and LICENSE files. */
/**
* For caching to the filesystem
*/
class Cache_Controller_File extends Cache_Controller {
/*
* Default location for cache
* @var String
*/
const CACHE_DIR = "tmp/cache";
/*
* Default file extension for cache files
*/
const CACHE_EXT = "cache.php";
/**
* @see Cache_Controller
*/
public function clear($key = NULL) {
// TODO
//
// Delete cache file where the filename is generated from
// $key
//
// If $key is null, delete all cache files
return false;
}
/**
* @see Cache_Controller
*/
public function get($name) {
// TODO
//
// Check if file exists
// Get contents from file
// unserialize cache object
// validate (check age)
// return cache object's data
return false;
}
/**
* @see Cache_Controller
*/
public function has($name) {
return file_exists($this->encode_filename($name));
}
/**
* @see Cache_Controller
*/
public function set($name, $object, $max_age = 0) {
// TODO
//
// Store cache object
return false;
}
/**
* Turn cachable name into file location
*
* @param String $name The name of to build from
* @return String
*/
protected static function encode_filename($name) {
return LIB_DIR . "/" .
self::CACHE_DIR . "/" .
str_replace("_", "/", $name) .
self::CACHE_EXT;
}
}
?>