Set whether or not to cache the results of this query and if so, for
how long and which ID to use for the cache entry.

@param boolean $bool
@param integer $lifetime
@param string  $resultCacheId

@return static This query instance.
343215
public function useResultCache($bool, $lifetime = null, $resultCacheId = null)
    {
        if ($bool) {
            $this->setResultCacheLifetime($lifetime);
            $this->setResultCacheId($resultCacheId);

            return $this;
        }

        $this->_queryCacheProfile = null;

        return $this;
    }
72686
public function remember($lifetime = null)
    {
        $this->shouldCache = true;

        // Make sure something other than the default value (null) is given.
        // Then resolve the DateTime instance from the given value.
        if ($lifetime !== null) {
            $this->cacheLifetime = $this->resolveCacheLifetime($lifetime);
        }

        return $this;
    }
151533
public function setResultCacheId($id)
    {
        $this->queryCacheProfile = $this->queryCacheProfile
            ? $this->queryCacheProfile->setCacheKey($id)
            : new QueryCacheProfile(0, $id, $this->em->getConfiguration()->getResultCacheImpl());

        return $this;
    }
674858
public function set($key, $value, $lifeTime)
    {

        $path = $this->getKeyPath($key);
        $dir = dirname($path);

        if (!is_dir($dir))
            mkdir($dir, 0777, true);

        $this->_lifeTimes[$key] = intval($lifeTime);

        //Save the life times
        $this->_format->save($this->_lifeTimePath, $this->_lifeTimes);

        //Save the cache content
        $this->_format->save($path, $value);

        return $this;
    }
611513
public function setResultCacheId($id)
    {
        $this->_queryCacheProfile = $this->_queryCacheProfile
            ? $this->_queryCacheProfile->setCacheKey($id)
            : new QueryCacheProfile(0, $id, $this->_em->getConfiguration()->getResultCacheImpl());

        return $this;
    }
464436
public function caching($bool = null)
	{
		if (is_bool($bool))
		{
			$this->_config['enable_cache'] = $bool;
			return $this;
		}
		return \Arr::get($this->_config, 'enable_cache', true);
	}
641053
public function getResultCache() {
    if (!isset($this->resultCache)) 
      $this->resultCache = new \Doctrine\Common\Cache\ArrayCache;
      
    return $this->resultCache;
  }
631803
public function setCache(CacheProvider $cache, $cacheNamespace, $cacheLifetime)
    {
        $this->cache = $cache;
        $this->cache->setNamespace($cacheNamespace);
        $this->cacheLifetime = $cacheLifetime;
    }
126359
public function getItem($cacheId, $withVersion = true, &$success = null)
    {
        if ($withVersion) {
            $cacheId .= '.' . $this->getVersion();
        }

        if (!$this->cache->hasItem($cacheId)) {
            $success = false;

            return null;
        }

        $success = null;
        $data    = $this->cache->getItem($cacheId, $success);

        if (!$success) {
            $success = false;

            return null;
        }

        if (!property_exists($data, 'content')) {
            $success = false;

            return null;
        }

        $success = true;

        return $data->content;
    }
1293467
public function set($id, $data, $lifetime = 0) {
		return $this->getBackend()->set($id, json_encode($data), $lifetime);
	}
42759
public function save($identifier, $data, $lifeTime = 0): bool
    {
        [$config, $key] = $this->configSplit($identifier);

        return CakeCache::write(static::CACHE_PREFIX . $key, $data, $config);
    }
310172
public function cache(Closure $callback, $lifetime = null, $returnObj = false)
    {
        if ($this->imageCache === null) {
            // create imagecache
            $this->imageCache = new ImageCache($this);
        }

        // run callback
        if (\is_callable($callback)) {
            $callback($this->imageCache);
        }

        return $this->imageCache->get($lifetime, $returnObj);
    }
588818
public function setResultCacheDriver($resultCacheDriver = null)
    {
        if ($resultCacheDriver !== null && ! ($resultCacheDriver instanceof \Doctrine\Common\Cache\Cache)) {
            throw InvalidResultCacheDriver::create();
        }

        $this->queryCacheProfile = $this->queryCacheProfile
            ? $this->queryCacheProfile->setResultCacheDriver($resultCacheDriver)
            : new QueryCacheProfile(0, null, $resultCacheDriver);

        return $this;
    }
315372
public function getItem($cacheId, & $success = null)
    {
        $cacheId = $this->normalizeKey($cacheId);

        /** @var $cache \Zend\Cache\Storage\Adapter\AbstractAdapter */
        $cache    = $this->cache;
        $casToken = null;

        try {
            $content = $cache->getItem($cacheId, $success, $casToken);
        } catch (ZendException\ExceptionInterface $ex) {
            $success = false;

            return null;
        }

        if (!$cache->hasPlugin(new Serializer())) {
            $content = unserialize($content);
        }

        return $content;
    }
296336
public function setCache($key, $data, $lifetimeInSeconds = false)
    {
        if ($this->sqlInitialized()) {
            if ($this->sql) {
                /* escape query data */
                $_key = $this->sql->real_escape_string($key);
                $_data = $this->sql->real_escape_string(serialize($data));
                $_expire = $this->getExpirationTimestamp($lifetimeInSeconds);

                $response = $this->sql->query("
                    SELECT *
                        FROM `{$this->table}`
                        WHERE
                            `{$this->key}` = '$_key'
                ");
                if ($response->fetch_assoc()) {
                    if ($this->sql->query("
                        UPDATE
                            `{$this->table}`
                            SET
                                `{$this->cache}` = '$_data',
                                `expire` = " . ($_expire === false ? 'NULL' : "'$_expire'") . "
                            WHERE
                                `{$this->key}` = '$_key'
                    ")) {
                        return true;
                    } else {
                        throw new SimpleCache_Exception(
                            'Could not update existing cache data. ' . $this->sql->error,
                            SimpleCache_Exception::CACHE_WRITE
                        );
                    }
                } elseif ($this->sql->query("
                    INSERT
                        INTO `{$this->table}`
                        (
                            `{$this->key}`,
                            `{$this->cache}`
                            " . ($_expire === false ? '' : ", `expire`") . "
                        ) VALUES (
                            '$_key',
                            '$_data'
                            " . ($_expire === false ? '' : ", '$_expire'") . "
                        )
                ")) {
                    return true;
                } else {
                    throw new SimpleCache_Exception(
                        'Could not insert new cache data. ' . $this->sql->error,
                        SimpleCache_Exception::CACHE_WRITE
                    );
                }
            }
            return false;
        }
    }
667524
protected function cacheSet(string $sql, $result, array $values = null, string $index = null, int $ttl = null):bool{

		if($this->cache instanceof CacheInterface){
			return $this->cache->set($this->cacheKey($sql, $values, $index), $result, $ttl);
		}

		return false; // @codeCoverageIgnore
	}
638253
protected function cacheViaTrait(string $entryIdentifier, callable $callback, string $cacheIdentifier, int $lifetime = 0, array $tags = [])
    {
        try {
            /** @var AbstractFrontend $cache */
            $cache = GeneralUtility::makeInstance(CacheManager::class)->getCache($cacheIdentifier);
        } catch (\Exception $ex) {
            $logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
            $logger->error($ex->getMessage(), ['entryIdentifier' => $entryIdentifier, 'cacheIdentifier' => $cacheIdentifier]);

            return \call_user_func_array($callback, []);
        }

        // Do not use "has" because the cache is a shared resource
        $result = $cache->get($entryIdentifier);
        if (false !== $result) {
            return $result;
        }
        $result = \call_user_func_array($callback, []);
        $cache->set($entryIdentifier, $result, $tags, 0 === $lifetime ? null : $lifetime);

        return $result;
    }