ApcCache.php in X Autoload 7.2
File
lib/ClassFinder/ApcCache.php
View source
<?php
class xautoload_ClassFinder_ApcCache {
protected $prefix;
protected $finder;
function __construct($finder, $prefix) {
if (!extension_loaded('apc') || !function_exists('apc_store')) {
throw new Exception('Unable to use xautoload_ClassFinder_ApcCache, as APC is not enabled.');
}
$this->finder = $finder;
$this->prefix = $prefix;
}
function findFile($api, $class) {
$key = $this->prefix . ':' . $class;
$file = apc_fetch($key);
if (!empty($file)) {
if ($api
->suggestFile($file)) {
return TRUE;
}
else {
apc_delete($key);
}
}
if ($this->finder
->findFile($api, $class)) {
apc_store($key, $api
->getFile());
return TRUE;
}
}
}