Chris@0: useCaches && $this->cacheBackend) { Chris@0: return $this->cacheBackend->get($cid); Chris@0: } Chris@0: return FALSE; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Stores data in the persistent cache, respecting the use caches flag. Chris@0: * Chris@0: * @param string $cid Chris@0: * The cache ID of the data to store. Chris@0: * @param mixed $data Chris@0: * The data to store in the cache. Chris@0: * Some storage engines only allow objects up to a maximum of 1MB in size to Chris@0: * be stored by default. When caching large arrays or similar, take care to Chris@0: * ensure $data does not exceed this size. Chris@0: * @param int $expire Chris@0: * One of the following values: Chris@0: * - CacheBackendInterface::CACHE_PERMANENT: Indicates that the item should Chris@0: * not be removed unless it is deleted explicitly. Chris@0: * - A Unix timestamp: Indicates that the item will be considered invalid Chris@0: * after this time, i.e. it will not be returned by get() unless Chris@0: * $allow_invalid has been set to TRUE. When the item has expired, it may Chris@0: * be permanently deleted by the garbage collector at any time. Chris@0: * @param array $tags Chris@0: * An array of tags to be stored with the cache item. These should normally Chris@0: * identify objects used to build the cache item, which should trigger Chris@0: * cache invalidation when updated. For example if a cached item represents Chris@0: * a node, both the node ID and the author's user ID might be passed in as Chris@0: * tags. For example array('node' => array(123), 'user' => array(92)). Chris@0: * Chris@0: * @see \Drupal\Core\Cache\CacheBackendInterface::set() Chris@0: */ Chris@0: protected function cacheSet($cid, $data, $expire = Cache::PERMANENT, array $tags = []) { Chris@0: if ($this->cacheBackend && $this->useCaches) { Chris@0: $this->cacheBackend->set($cid, $data, $expire, $tags); Chris@0: } Chris@0: } Chris@0: Chris@0: }