文件缓存

@param array $config 配置参数
@return \phpFastCache\Core\DriverAbstract
481238
private function file($config = array()) {
        $filePath = $config['filePath'];

        if (!file_exists($filePath)) {
            Filesystem::mkdir($filePath);
        }
        //初始化缓存路径
        CacheManager::setup(array(
            "path" => isset($filePath) ? $filePath : sys_get_temp_dir(), // or in windows "C:/tmp/"
        ));
        CacheManager::CachingMethod("phpfastcache");

        //初始化缓存
        $InstanceCache = CacheManager::Files();

        return $InstanceCache;
    }
1224131
protected function doSetup($config = array())
    {
        // Catch the configuration file path
        if (isset($config[self::CONFIG_KEY_FILE_PATH])) {
            $this->configFilePath = $config[self::CONFIG_KEY_FILE_PATH];
        } else {
            // Also consider throwing an exception here instead
            // of failing silently
            return $config;
        }

        // Catch the context
        if (isset($config[ConfigInterface::KEY_CONTEXT])) {
            $this->context = $config[ConfigInterface::KEY_CONTEXT];
        }

        return $this->readConfigurationFiles();
    }
1050401
public static function unserialize(array $config)
    {
        $configuration = new static;

        if (false !== ($clientConfiguration = unserialize($config['watched_files']))) {
            $configuration->set($clientConfiguration);
        }

        return $configuration;
    }
117558
public static function get(array $config)
    {
        if (!isset($config['driver']) || !$config['driver']) {
            throw new \RuntimeException('no driver specified');
        }

        $driver = strtolower($config['driver']);

        if (!in_array($driver, array('sqlite', 'mysql', 'sqlserver', 'postgre'), true)) {
            throw new \UnexpectedValueException('PDO driver "' . $driver . '" not supported by PIMF');
        }

        if (!extension_loaded('pdo') || !extension_loaded('pdo_' . $driver)) {
            throw new \RuntimeException('Please navigate to "http://php.net/manual/pdo.installation.php" '
                . ' to find out how to install "PDO" with "pdo_' . $driver . '" on your system!');
        }

        $driver = '\Pimf\Pdo\\' . ucfirst($driver);

        $pdo = new $driver();

        return $pdo->connect($config);
    }
603802
public function load(array $config = [])
    {
        $this->config = array_replace_recursive($this->config, $config);

        $this->enviroment();
        $this->errors();
        $this->templates();
        $this->orm();
        $this->router();

        return $this;
    }
1139179
public function connect(array $config){
		Connection::alias($config, 'database', 'file');
		Connection::alias($config, 'updateLimit', 'update_limit');

		$defaults = array(
			'memory' => false,
			'resource' => null,
			'updateLimit' => false,
			'charset' => 'UTF-8',
			'dbcharset' => 'UTF-8'
		);

		$config += $defaults;

		if($config['memory'])
			$config['database'] = ':memory:';

		// Connect
		if($config['resource'] instanceof SQLite3)
			$connection = $config['resource'];
		elseif(!isset($config['database']))
			throw new DriverException("No database file selected.");
		else{
			try{
				$connection = new SQLite3($config['database']);
			} catch(Exception $e){
				throw new DriverException($e->getMessage(), $e->getCode());
			}
		}

		if(!$connection instanceof SQLite3)
			throw new DriverException("Opening database file '$config[database]' failed.");

		$this->resource = $connection;
		$this->updateLimit = (bool) $config['updateLimit'];

		// Set charset
		$this->dbCharset = $config['dbcharset'];
		$this->charset = $config['charset'];
		if(strcasecmp($this->dbCharset, $this->charset) === 0)
			$this->dbCharset = $this->charset = null;
	}
952382
public function save(array $config): CacheLoader
    {
        file_put_contents($this->getFilename(), sprintf(
            '<?php return %s;',
            var_export($config, true)
        ));

        return $this;
    }
565174
public static function create(array $config = [])
    {
        if (!isset($config['driver'])) {
            throw new InvalidArgumentException("'driver' in config missing");
        }
        if (!isset($config['drivers'][$config['driver']])) {
            throw new InvalidArgumentException("driver '{$config['driver']}' is not configured");
        }
        if (!isset($config['drivers'][$config['driver']]['tagHeaderName'])) {
            throw new InvalidArgumentException("'tagHeaderName' is not configured");
        }

        $driverConfig = $config['drivers'][$config['driver']];
        $driverClass = $driverConfig['class'] ?? self::DRIVERS_NAMESPACE . '\\' . ucfirst($config['driver']);

        // tagHeaderName and tagHeaderDelimiter are not relevant to the Purger
        unset($driverConfig['tagHeaderName'], $driverConfig['tagHeaderDelimiter']);
        return \Craft::createObject($driverClass,[$driverConfig + ['useLocalTags' => $config['useLocalTags']]]);

    }
989039
public static function pdo(array $config = []): DB
    {
        [$hash, $config] = static::getKey($config, 'database');

        if (isset(static::$pool[$hash])) {
            return static::$pool[$hash];
        }

        $driver = $config['driver'] ?? '';

        if ($driver === 'develop' && !Debugger::$productionMode) {
            return static::$pool[$hash] = new Develop($config);
        }

        return static::$pool[$hash] = new DB($config);
    }
759141
protected function createRedisDriver( array $config )
	{
		$redis = Framework::get( 'redis' );

		$connection = Arr::get( $config, 'connection', 'default' );

		return new RedisStore( $redis, $this->getPrefix( $config ), $connection );
	}
1158155
protected function getClient(array $config)
    {
        $name = array_get($config, 'connector');

        return $this->cache->driver($name)->getStore();
    }
476225
public function config(array $config)
    {
        parent::config($config);

        if (array_key_exists('fingerprint', $config)) {
            $this->defaults->setFingerprint($config['fingerprint']);
        }

        if (array_key_exists('path', $config)) {
            $this->defaults->setPath($config['path']);
        }

        if (array_key_exists('local_path', $config)) {
            $this->defaults->setLocalPath($config['local_path']);
        }

        if (array_key_exists('pattern', $config)) {
            $this->defaults->setPattern($config['pattern']);
        }

        if (array_key_exists('files_callback', $config)) {
            $this->defaults->setFilesCallback($config['files_callback']);
        }

        if (array_key_exists('do_cleanup', $config)) {
            $this->defaults->setDoCleanup($config['do_cleanup']);
        }

        return $this;
    }
1347345
private static function parseConfig($config)
    {
        if (empty($config)) {
            $config = Container::get('config')->pull('database');
        } elseif (is_string($config) && false === strpos($config, '/')) {
            // 支持读取配置参数
            $config = Container::get('config')->get('database.' . $config);
        }

        if (is_string($config)) {
            return self::parseDsnConfig($config);
        } else {
            return $config;
        }
    }
1110482
public function load(array $config)
    {
        $config = $this->getParsedConfig(
            $config,
            $this->config,
            $this->yamlConfigMap,
            $this->required
        );
        $this->setParsedConfig($config);

        return $this;
    }
1190216
private function buildDriver(array $driverConfig)
    {
        $class = array_get($driverConfig, 'class', '');
        if ($class && class_exists($class)) {
            $implements = class_implements($class);

            // Make sure that the provided class implements the DriverInterface
            if (isset($implements['Stash\Interfaces\DriverInterface'])) {
                /* @var \Stash\Interfaces\DriverInterface $tempDriver */

                // Only add if the driver is available
                if ($class::isAvailable()) {
                    $tempDriver = new $class(array_get($driverConfig, 'options', null));

                    return $tempDriver;
                }
            } else {
                throw new \RuntimeException('Cache driver class must implement \Stash\Interfaces\DriverInterface.');
            }
        }

        return null;
    }
457775
public static function get($key,$config)
    {
        static::initGet($key,$config);
        if(file_exists(static::$path )){
            /**
             * 获取数据
             */
            static:: $data = unserialize(file_get_contents(static::$path));

            if(static:: $data['period'] >time() || static:: $data['period']==0 ){
                $data = static:: $data['data'];
                /**
                 * 清除 static  信息
                 * 防止数据错误
                 */
                static::staticEmpty();
                return $data;
            }
            /**
             * 删除
             */
            unlink(static::$path);
        }
        /**
         * 清除 static  信息
         * 防止数据错误
         */
        static::staticEmpty();
        return NULL;
    }
930396
protected function createMemcachedDriver(array $config)
    {
        $prefix = $this->getPrefix($config);

        // Extract Plus features from config
        $persistentConnectionId = array_get($config, 'persistent_id');
        $customOptions = array_get($config, 'options', []);
        $saslCredentials = array_filter(array_get($config, 'sasl', []));

        $memcached = $this->app['memcached.connector']->connect(
            $config['servers'],
            $persistentConnectionId,
            $customOptions,
            $saslCredentials
        );

        return $this->repository(new MemcachedStore($memcached, $prefix));
    }