/** * 连接缓存 * @access public * @param array $options 配置数组 * @return object */ public static function connect($options = []) { $type = !empty($options['type']) ? $options['type'] : 'File'; $class = 'think\\cache\\driver\\' . ucwords($type); self::$handler = new $class($options); return self::$handler; }
/** * 连接缓存 * @access public * @param array $options 配置数组 * @return object */ public static function connect(array $options = []) { $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; }
/** * 连接缓存 * @access public * @param array $options 配置数组 * @return object */ public static function connect(array $options = []) { $md5 = md5(serialize($options)); if (!isset(self::$instance[$md5])) { $type = !empty($options['type']) ? $options['type'] : 'File'; $class = (!empty($options['namespace']) ? $options['namespace'] : '\\think\\cache\\driver\\') . ucwords($type); unset($options['type']); self::$instance[$md5] = new $class($options); } self::$handler = self::$instance[$md5]; return self::$handler; }
/** * 连接缓存 * @access public * @param array $options 配置数组 * @return object */ public static function connect(array $options = []) { $md5 = md5(serialize($options)); if (!isset(self::$instance[$md5])) { $type = !empty($options['type']) ? $options['type'] : 'File'; $class = (!empty($options['namespace']) ? $options['namespace'] : '\\think\\cache\\driver\\') . ucwords($type); unset($options['type']); self::$instance[$md5] = new $class($options); // 记录初始化信息 APP_DEBUG && Log::record('[ CACHE ] INIT ' . $type . ':' . var_export($options, true), 'info'); } self::$handler = self::$instance[$md5]; return self::$handler; }
/** * 连接缓存 * @access public * @param array $options 配置数组 * @param bool|string $name 缓存连接标识 true 强制重新连接 * @return object */ public static function connect(array $options = [], $name = false) { $type = !empty($options['type']) ? $options['type'] : 'File'; if (false === $name) { $name = $type; } if (true === $name || !isset(self::$instance[$name])) { $class = false !== strpos($type, '\\') ? $type : '\\think\\cache\\driver\\' . ucwords($type); // 记录初始化信息 App::$debug && Log::record('[ CACHE ] INIT ' . $type . ':' . var_export($options, true), 'info'); if (true === $name) { return new $class($options); } else { self::$instance[$name] = new $class($options); } } self::$handler = self::$instance[$name]; return self::$handler; }