php-censor/src/B8Framework/Cache.php
2017-11-08 20:45:18 +07:00

32 lines
583 B
PHP

<?php
namespace b8;
class Cache
{
const TYPE_APC = 'ApcCache';
const TYPE_REQUEST = 'RequestCache';
/**
* @var array
*/
protected static $instance = [];
/**
* Get a cache object of a specified type.
*
* @param string $type
*
* @return mixed
*/
public static function getCache($type = self::TYPE_REQUEST)
{
if (!isset(self::$instance[$type])) {
$class = '\\b8\\Cache\\' . $type;
self::$instance[$type] = new $class();
}
return self::$instance[$type];
}
}