function UseCacheBackendTrait::cacheSet
Same name in other branches
- 9 core/lib/Drupal/Core/Cache/UseCacheBackendTrait.php \Drupal\Core\Cache\UseCacheBackendTrait::cacheSet()
- 10 core/lib/Drupal/Core/Cache/UseCacheBackendTrait.php \Drupal\Core\Cache\UseCacheBackendTrait::cacheSet()
- 11.x core/lib/Drupal/Core/Cache/UseCacheBackendTrait.php \Drupal\Core\Cache\UseCacheBackendTrait::cacheSet()
Stores data in the persistent cache, respecting the use caches flag.
Parameters
string $cid: The cache ID of the data to store.
mixed $data: The data to store in the cache. Some storage engines only allow objects up to a maximum of 1MB in size to be stored by default. When caching large arrays or similar, take care to ensure $data does not exceed this size.
int $expire: One of the following values:
- CacheBackendInterface::CACHE_PERMANENT: Indicates that the item should not be removed unless it is deleted explicitly.
- A Unix timestamp: Indicates that the item will be considered invalid after this time, i.e. it will not be returned by get() unless $allow_invalid has been set to TRUE. When the item has expired, it may be permanently deleted by the garbage collector at any time.
array $tags: An array of tags to be stored with the cache item. These should normally identify objects used to build the cache item, which should trigger cache invalidation when updated. For example if a cached item represents a node, both the node ID and the author's user ID might be passed in as tags. For example array('node' => array(123), 'user' => array(92)).
See also
\Drupal\Core\Cache\CacheBackendInterface::set()
11 calls to UseCacheBackendTrait::cacheSet()
- DefaultPluginManager::setCachedDefinitions in core/
lib/ Drupal/ Core/ Plugin/ DefaultPluginManager.php - Sets a cache of plugin definitions for the decorated discovery class.
- EntityDisplayRepository::getAllDisplayModesByEntityType in core/
lib/ Drupal/ Core/ Entity/ EntityDisplayRepository.php - Gets the entity display mode info for all entity types.
- EntityFieldManager::getBaseFieldDefinitions in core/
lib/ Drupal/ Core/ Entity/ EntityFieldManager.php - Gets the base field definitions for a content entity type.
- EntityFieldManager::getExtraFields in core/
lib/ Drupal/ Core/ Entity/ EntityFieldManager.php - Gets the "extra fields" for a bundle.
- EntityFieldManager::getFieldDefinitions in core/
lib/ Drupal/ Core/ Entity/ EntityFieldManager.php - Gets the field definitions for a specific bundle.
File
-
core/
lib/ Drupal/ Core/ Cache/ UseCacheBackendTrait.php, line 69
Class
- UseCacheBackendTrait
- Provides methods to use a cache backend while respecting a 'use caches' flag.
Namespace
Drupal\Core\CacheCode
protected function cacheSet($cid, $data, $expire = Cache::PERMANENT, array $tags = []) {
if ($this->cacheBackend && $this->useCaches) {
$this->cacheBackend
->set($cid, $data, $expire, $tags);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.