public function FileMetadataPluginBase::saveMetadataToCache in File metadata manager 8
Same name and namespace in other branches
- 8.2 src/Plugin/FileMetadata/FileMetadataPluginBase.php \Drupal\file_mdm\Plugin\FileMetadata\FileMetadataPluginBase::saveMetadataToCache()
Caches metadata for file at URI.
Uses the 'file_mdm' cache bin.
Parameters
array $tags: (optional) An array of cache tags to save to cache.
Return value
bool TRUE if metadata was saved successfully, FALSE otherwise.
Overrides FileMetadataPluginInterface::saveMetadataToCache
2 calls to FileMetadataPluginBase::saveMetadataToCache()
- FileMetadataPluginBase::loadMetadata in src/
Plugin/ FileMetadata/ FileMetadataPluginBase.php - Loads file metadata from an in-memory object/array.
- FileMetadataPluginBase::loadMetadataFromFile in src/
Plugin/ FileMetadata/ FileMetadataPluginBase.php - Loads file metadata from the file at URI/local path.
File
- src/
Plugin/ FileMetadata/ FileMetadataPluginBase.php, line 497
Class
- FileMetadataPluginBase
- Abstract implementation of a base File Metadata plugin.
Namespace
Drupal\file_mdm\Plugin\FileMetadataCode
public function saveMetadataToCache(array $tags = []) {
if ($this->metadata === NULL) {
return FALSE;
}
if (($cache_settings = $this
->isUriFileMetadataCacheable()) === FALSE) {
return FALSE;
}
if ($this->isMetadataLoaded !== FileMetadataInterface::LOADED_FROM_CACHE || $this->isMetadataLoaded === FileMetadataInterface::LOADED_FROM_CACHE && $this->hasMetadataChangedFromCacheVersion) {
$tags = Cache::mergeTags($tags, $this
->getConfigObject()
->getCacheTags());
$tags = Cache::mergeTags($tags, $this->configFactory
->get('file_mdm.settings')
->getCacheTags());
$expire = $cache_settings['expiration'] === -1 ? Cache::PERMANENT : time() + $cache_settings['expiration'];
$this->cache
->set("hash:{$this->getPluginId()}:{$this->hash}", $this
->getMetadataToCache(), $expire, $tags);
$this->hasMetadataChangedFromCacheVersion = FALSE;
return TRUE;
}
return FALSE;
}