驱动设计支持使用 namespace配置改变默认命名空间位置

This commit is contained in:
thinkphp
2015-12-26 17:59:07 +08:00
parent bd322b82e5
commit a746982703
7 changed files with 19 additions and 11 deletions

View File

@@ -13,8 +13,8 @@ namespace think;
class Cache
{
public static $readTimes = 0;
public static $writeTimes = 0;
public static $readTimes = 0;
public static $writeTimes = 0;
/**
* 操作句柄
@@ -31,8 +31,9 @@ class Cache
*/
public static function connect($options = [])
{
$type = !empty($options['type']) ? $options['type'] : 'File';
$class = '\\think\\cache\\driver\\' . ucwords($type);
$type = !empty($options['type']) ? $options['type'] : 'File';
$class = (!empty($options['namespace']) ? $options['namespace'] : '\\think\\cache\\driver\\') . ucwords($type);
unset($options['type']);
self::$handler = new $class($options);
return self::$handler;
}