Adds a Cache

@param CacheInterface $cache
517527
public function addCache(CacheInterface $cache)
    {
        $this->cacheMap[$cache->getName()] = $cache;
        $this->cacheNames[]                = $cache->getName();
    }
1334924
private function saveToCache($key, MenuInterface $menu)
    {
        $encodedMenu = $this
            ->encoder
            ->encode($menu);

        $this
            ->cache
            ->save($key, $encodedMenu);

        return $this;
    }
186329
protected function addMemcacheServers($cache, $servers)
    {
        $class = new \ReflectionClass($cache);
        $paramCount = $class->getMethod('addServer')->getNumberOfParameters();
        foreach ($servers as $server) {
            // $timeout is used for memcache versions that do not have $timeoutms parameter
            $timeout = (int) ($server->timeout / 1000) + (($server->timeout % 1000 > 0) ? 1 : 0);
            if ($paramCount === 9) {
                $cache->addServer(
                    $server->host,
                    $server->port,
                    $server->persistent,
                    $server->weight,
                    $timeout,
                    $server->retryInterval,
                    $server->status,
                    $server->failureCallback,
                    $server->timeout
                );
            } else {
                $cache->addServer(
                    $server->host,
                    $server->port,
                    $server->persistent,
                    $server->weight,
                    $timeout,
                    $server->retryInterval,
                    $server->status,
                    $server->failureCallback
                );
            }
        }
    }
212070
public function setCache(Mustache_Cache $cache)
    {
        if (isset($this->logger) && $cache->getLogger() === null) {
            $cache->setLogger($this->getLogger());
        }

        $this->cache = $cache;
    }
1254999
public function load(Cache $cache, $cacheId)
    {
        if ($cache->contains($cacheId)) {

            /**
             * Cache contains gearman structure
             */
            $this->workerCollection = $cache->fetch($cacheId);

        } else {

            /**
             * Cache is empty.
             *
             * Full structure must be generated and cached
             */
            $this->workerCollection = $this
                ->getGearmanParser()
                ->load()
                ->toArray();

            $cache->save($cacheId, $this->workerCollection);
        }

        return $this;
    }
137102
public function withVerifierCache($cache): self
    {
        if (!is_a($cache, $expected = 'Psr\SimpleCache\CacheInterface')) {
            throw new InvalidArgumentException('The verififier cache must be an instance of '.$expected);
        }

        $factory = clone $this;
        $factory->verifierCache = $cache;

        return $factory;
    }
163695
public function update_hyphenator_cache( Cache $cache ) {
		foreach ( $this->token_fixes as $fix ) {
			if ( $fix instanceof Hyphenate_Fix ) {
				$fix->set_hyphenator_cache( $cache );
			}
		}
	}
184658
protected function instantiateCache(Cache $cache = null)
    {
        if (is_null($this->cache) || ! is_null($cache)) {
            $this->cache = ! is_null($cache)
                ? $cache
                : new Cache($this->config);
        }

        return $this->cache;
    }
733328
private function deletePageCache(PageInterface $page)
    {
        if (null !== $this->cache) {
            $this->cache->delete('ekyna_cms.page[route:' . $page->getRoute() . ']');
        }
    }
774416
public function setCache($useCache, $tableTTL, \Slab\Components\Cache\DriverInterface $cacheObject)
    {
        $this->cacheInterface = $cacheObject;
        $this->cacheTTL = $tableTTL;
        $this->enableCache = $useCache;

        return $this;
    }
743155
public function set(CacheableInterface $item)
    {
        parent::set($item);
        $this->adapter->set($item);
    }
159206
private function saveIntoCache($key, MessageInterface $message)
    {
        if ($this->cache) {
            $item = $this->cache->getItem($key);

            $item->set([
                $message->getHeaders(),
                (string) $message->getBody(),
            ]);

            $this->cache->save($item);
        }
    }
452147
public function setCache(FrontendInterface $cache)
    {
        parent::setCache($cache);
        $this->cacheEntryFileExtension = ($cache instanceof PhpFrontend) ? '.php' : '';
        $this->configureCacheDirectory();
    }
179569
public function cache(Store $cache = null)
    {
        $cache = $cache ?: $this->resolve(CacheRepository::class)->getStore();

        if ($this->usesCachedClipboard()) {
            $this->guard->getClipboard()->setCache($cache);

            return $this;
        }

        return $this->setClipboard(new CachedClipboard($cache));
    }
1026256
private function saveFileToCache(FileInterface $file)
    {
        $cachedPath = sys_get_temp_dir() . self::CACHE_DIR . $file->getRelativePath();

        if (! is_dir(dirname($cachedPath))) {
            mkdir(dirname($cachedPath), 0700, true);
        }

        $cmd = sprintf('git show :%s > %s', $file->getRelativePath(), $cachedPath);
        $process = new Process($cmd);
        $process->run();

        $file->setCachedPath($cachedPath);

        return $file;
    }
691400
protected function executeCache(ContainerInterface $container, IoInterface $inOut): void
    {
        assert($inOut);

        $appConfig     = $this->getApplicationConfiguration($container);
        $cacheDir      = $appConfig[ApplicationConfigurationInterface::KEY_CACHE_FOLDER];
        $cacheCallable = $appConfig[ApplicationConfigurationInterface::KEY_CACHE_CALLABLE];
        list ($namespace, $class, $method) = $this->parseCacheCallable($cacheCallable);
        if ($class === null || $namespace === null || $method === null) {
            // parsing of cache callable failed (most likely error in settings)
            throw new ConfigurationException();
        }

        /** @var CacheSettingsProviderInterface $settingsProvider */
        $settingsProvider = $container->get(CacheSettingsProviderInterface::class);
        $settingsData     = $settingsProvider->serialize();
        $content          = $this->composeContent($settingsData, $namespace, $class, $method);

        $path = $cacheDir . DIRECTORY_SEPARATOR . $class . '.php';
        $this->getFileSystem($container)->write($path, $content);

        $inOut->writeInfo('Cache created.' . PHP_EOL);
        $inOut->writeInfo("Cache written to `$path`." . PHP_EOL, IoInterface::VERBOSITY_VERBOSE);
    }
638010
public function decorate(&$cache)
    {
        $decorator = $this->copy();
        // reference is necessary for mocks in PHP 4
        $decorator->cache =& $cache;
        $decorator->type = $cache->type;
        return $decorator;
    }