drivers[$name]) && $this->drivers[$name] instanceof DriverInterface) { return $this->drivers[$name]; } $config = $this->config->get("cache.{$name}"); if (empty($config)) { throw new InvalidArgumentException(sprintf('The cache config %s is invalid.', $name)); } $driverClass = $config['driver'] ?? RedisDriver::class; $driver = make($driverClass, ['config' => $config]); return $this->drivers[$name] = $driver; } public function call(callable $callback, string $key, int $ttl = 3600, $config = 'default') { $driver = $this->getDriver($config); [$has, $result] = $driver->fetch($key); if ($has) { return $result; } $result = $callback(); $driver->set($key, $result, $ttl); return $result; } }