<?php
namespace GK;
use GK\Cache\Driver;
class Cache
{
public static $Instance = [];
public static $ReadTimes = 0;
public static $WriteTimes = 0;
public static $Handler;
public static function Connect(array $options = [], $name = false)
{
$type = !empty($options['type']) ? $options['type'] : 'File';
if (false === $name) {
$name = md5(serialize($options));
}
if (true === $name || !isset(self::$Instance[$name])) {
$class = false === strpos($type, '\\') ?
'\\think\\cache\\driver\\' . ucwords($type) :
$type;
App::$debug && Log::record('[ CACHE ] INIT ' . $type, 'info');
if (true === $name) {
return new $class($options);
}
self::$Instance[$name] = new $class($options);
}
return self::$Instance[$name];
}
}