Commit b8ef75c5 authored by webchick's avatar webchick

Issue #2169447 by damiankloip, sun, longwave: DX: Supply...

Issue #2169447 by damiankloip, sun, longwave: DX: Supply CacheBackendInterface::CACHE_PERMANENT as Cache::PERMANENT.
parent 394442e2
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
use Drupal\Component\PhpStorage\PhpStorageFactory; use Drupal\Component\PhpStorage\PhpStorageFactory;
use Drupal\Component\Utility\MapArray; use Drupal\Component\Utility\MapArray;
use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Routing\GeneratorNotInitializedException; use Drupal\Core\Routing\GeneratorNotInitializedException;
use Drupal\Core\SystemListingInfo; use Drupal\Core\SystemListingInfo;
...@@ -3149,7 +3148,7 @@ function drupal_page_set_cache(Response $response, Request $request) { ...@@ -3149,7 +3148,7 @@ function drupal_page_set_cache(Response $response, Request $request) {
'page_compressed' => $page_compressed, 'page_compressed' => $page_compressed,
), ),
'tags' => array('content' => TRUE) + drupal_cache_tags_page_get(), 'tags' => array('content' => TRUE) + drupal_cache_tags_page_get(),
'expire' => CacheBackendInterface::CACHE_PERMANENT, 'expire' => Cache::PERMANENT,
'created' => REQUEST_TIME, 'created' => REQUEST_TIME,
); );
...@@ -4103,7 +4102,7 @@ function drupal_render_cache_set(&$markup, array $elements) { ...@@ -4103,7 +4102,7 @@ function drupal_render_cache_set(&$markup, array $elements) {
} }
$bin = isset($elements['#cache']['bin']) ? $elements['#cache']['bin'] : 'cache'; $bin = isset($elements['#cache']['bin']) ? $elements['#cache']['bin'] : 'cache';
$expire = isset($elements['#cache']['expire']) ? $elements['#cache']['expire'] : CacheBackendInterface::CACHE_PERMANENT; $expire = isset($elements['#cache']['expire']) ? $elements['#cache']['expire'] : Cache::PERMANENT;
$tags = drupal_render_collect_cache_tags($elements); $tags = drupal_render_collect_cache_tags($elements);
cache($bin)->set($cid, $data, $expire, $tags); cache($bin)->set($cid, $data, $expire, $tags);
} }
...@@ -4418,7 +4417,7 @@ function drupal_cache_tags_page_get() { ...@@ -4418,7 +4417,7 @@ function drupal_cache_tags_page_get() {
* - #pre_render: $function with a _pre_render suffix. * - #pre_render: $function with a _pre_render suffix.
* - #cache: An associative array prepared for drupal_render_cache_set(). * - #cache: An associative array prepared for drupal_render_cache_set().
*/ */
function drupal_render_cache_by_query($query, $function, $expire = CacheBackendInterface::CACHE_PERMANENT, $granularity = NULL) { function drupal_render_cache_by_query($query, $function, $expire = Cache::PERMANENT, $granularity = NULL) {
$cache_keys = array_merge(array($function), drupal_render_cid_parts($granularity)); $cache_keys = array_merge(array($function), drupal_render_cid_parts($granularity));
$query->preExecute(); $query->preExecute();
$cache_keys[] = hash('sha256', serialize(array((string) $query, $query->getArguments()))); $cache_keys[] = hash('sha256', serialize(array((string) $query, $query->getArguments())));
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Entity API for handling entities like nodes or users. * Entity API for handling entities like nodes or users.
*/ */
use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\Cache;
use Drupal\Core\Entity\EntityStorageException; use Drupal\Core\Entity\EntityStorageException;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Language\Language; use Drupal\Core\Language\Language;
...@@ -131,7 +131,7 @@ function entity_get_form_modes($entity_type = NULL) { ...@@ -131,7 +131,7 @@ function entity_get_form_modes($entity_type = NULL) {
$form_modes[$form_mode_entity_type][$form_mode_name] = (array) $form_mode; $form_modes[$form_mode_entity_type][$form_mode_name] = (array) $form_mode;
} }
drupal_alter('entity_form_mode_info', $form_modes); drupal_alter('entity_form_mode_info', $form_modes);
cache()->set("entity_form_mode_info:$langcode", $form_modes, CacheBackendInterface::CACHE_PERMANENT, array('entity_info' => TRUE)); cache()->set("entity_form_mode_info:$langcode", $form_modes, Cache::PERMANENT, array('entity_info' => TRUE));
} }
} }
...@@ -169,7 +169,7 @@ function entity_get_view_modes($entity_type = NULL) { ...@@ -169,7 +169,7 @@ function entity_get_view_modes($entity_type = NULL) {
$view_modes[$view_mode_entity_type][$view_mode_name] = (array) $view_mode; $view_modes[$view_mode_entity_type][$view_mode_name] = (array) $view_mode;
} }
drupal_alter('entity_view_mode_info', $view_modes); drupal_alter('entity_view_mode_info', $view_modes);
cache()->set("entity_view_mode_info:$langcode", $view_modes, CacheBackendInterface::CACHE_PERMANENT, array('entity_info' => TRUE)); cache()->set("entity_view_mode_info:$langcode", $view_modes, Cache::PERMANENT, array('entity_info' => TRUE));
} }
} }
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\NestedArray;
use Drupal\Component\Utility\String; use Drupal\Component\Utility\String;
use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Language\Language; use Drupal\Core\Language\Language;
use Drupal\Core\Routing\RequestHelper; use Drupal\Core\Routing\RequestHelper;
use Drupal\Core\Template\Attribute; use Drupal\Core\Template\Attribute;
...@@ -1216,7 +1215,7 @@ function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) { ...@@ -1216,7 +1215,7 @@ function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) {
} }
// Cache the tree building parameters using the page-specific cid. // Cache the tree building parameters using the page-specific cid.
cache('menu')->set($cid, $tree_parameters, CacheBackendInterface::CACHE_PERMANENT, array('menu' => $menu_name)); cache('menu')->set($cid, $tree_parameters, Cache::PERMANENT, array('menu' => $menu_name));
} }
// Build the tree using the parameters; the resulting tree will be cached // Build the tree using the parameters; the resulting tree will be cached
...@@ -1402,7 +1401,7 @@ function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail = ...@@ -1402,7 +1401,7 @@ function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail =
$tree_parameters['active_trail'] = $active_trail; $tree_parameters['active_trail'] = $active_trail;
} }
// Cache the tree building parameters using the page-specific cid. // Cache the tree building parameters using the page-specific cid.
cache('menu')->set($cid, $tree_parameters, CacheBackendInterface::CACHE_PERMANENT, array('menu' => $menu_name)); cache('menu')->set($cid, $tree_parameters, Cache::PERMANENT, array('menu' => $menu_name));
} }
// Build the tree using the parameters; the resulting tree will be cached // Build the tree using the parameters; the resulting tree will be cached
...@@ -1513,7 +1512,7 @@ function _menu_build_tree($menu_name, array $parameters = array()) { ...@@ -1513,7 +1512,7 @@ function _menu_build_tree($menu_name, array $parameters = array()) {
menu_tree_collect_node_links($data['tree'], $data['node_links']); menu_tree_collect_node_links($data['tree'], $data['node_links']);
// Cache the data, if it is not already in the cache. // Cache the data, if it is not already in the cache.
cache('menu')->set($tree_cid, $data, CacheBackendInterface::CACHE_PERMANENT, array('menu' => $menu_name)); cache('menu')->set($tree_cid, $data, Cache::PERMANENT, array('menu' => $menu_name));
$trees[$tree_cid] = $data; $trees[$tree_cid] = $data;
} }
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
*/ */
use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Database\Database; use Drupal\Core\Database\Database;
use Drupal\Core\Utility\SchemaCache; use Drupal\Core\Utility\SchemaCache;
...@@ -100,7 +99,7 @@ function drupal_get_complete_schema($rebuild = FALSE) { ...@@ -100,7 +99,7 @@ function drupal_get_complete_schema($rebuild = FALSE) {
// If the schema is empty, avoid saving it: some database engines require // If the schema is empty, avoid saving it: some database engines require
// the schema to perform queries, and this could lead to infinite loops. // the schema to perform queries, and this could lead to infinite loops.
if (!empty($schema) && (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL)) { if (!empty($schema) && (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL)) {
cache()->set('schema', $schema, CacheBackendInterface::CACHE_PERMANENT, array('schema' => TRUE)); cache()->set('schema', $schema, Cache::PERMANENT, array('schema' => TRUE));
} }
} }
} }
......
...@@ -123,7 +123,7 @@ public function getMultiple(&$cids, $allow_invalid = FALSE) { ...@@ -123,7 +123,7 @@ public function getMultiple(&$cids, $allow_invalid = FALSE) {
/** /**
* Implements Drupal\Core\Cache\CacheBackendInterface::set(). * Implements Drupal\Core\Cache\CacheBackendInterface::set().
*/ */
public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) { public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) {
foreach ($this->backends as $backend) { foreach ($this->backends as $backend) {
$backend->set($cid, $data, $expire, $tags); $backend->set($cid, $data, $expire, $tags);
} }
......
...@@ -12,6 +12,11 @@ ...@@ -12,6 +12,11 @@
*/ */
class Cache { class Cache {
/**
* Indicates that the item should never be removed unless explicitly deleted.
*/
const PERMANENT = CacheBackendInterface::CACHE_PERMANENT;
/** /**
* Deletes items from all bins with any of the specified tags. * Deletes items from all bins with any of the specified tags.
* *
......
...@@ -146,7 +146,7 @@ public function getMultiple(&$cids, $allow_invalid = FALSE); ...@@ -146,7 +146,7 @@ public function getMultiple(&$cids, $allow_invalid = FALSE);
* @see \Drupal\Core\Cache\CacheBackendInterface::get() * @see \Drupal\Core\Cache\CacheBackendInterface::get()
* @see \Drupal\Core\Cache\CacheBackendInterface::getMultiple() * @see \Drupal\Core\Cache\CacheBackendInterface::getMultiple()
*/ */
public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()); public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array());
/** /**
* Deletes an item from the cache. * Deletes an item from the cache.
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
namespace Drupal\Core\Cache; namespace Drupal\Core\Cache;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\DestructableInterface; use Drupal\Core\DestructableInterface;
use Drupal\Core\Lock\LockBackendInterface; use Drupal\Core\Lock\LockBackendInterface;
...@@ -242,7 +241,7 @@ protected function updateCache($lock = TRUE) { ...@@ -242,7 +241,7 @@ protected function updateCache($lock = TRUE) {
foreach ($this->keysToRemove as $delete_key) { foreach ($this->keysToRemove as $delete_key) {
unset($data[$delete_key]); unset($data[$delete_key]);
} }
$this->cache->set($this->cid, $data, CacheBackendInterface::CACHE_PERMANENT, $this->tags); $this->cache->set($this->cid, $data, Cache::PERMANENT, $this->tags);
if ($lock) { if ($lock) {
$this->lock->release($lock_name); $this->lock->release($lock_name);
} }
......
...@@ -118,7 +118,7 @@ protected function prepareItem($cache, $allow_invalid) { ...@@ -118,7 +118,7 @@ protected function prepareItem($cache, $allow_invalid) {
} }
// Check expire time. // Check expire time.
$cache->valid = $cache->expire == CacheBackendInterface::CACHE_PERMANENT || $cache->expire >= REQUEST_TIME; $cache->valid = $cache->expire == Cache::PERMANENT || $cache->expire >= REQUEST_TIME;
// Check if invalidateTags() has been called with any of the entry's tags. // Check if invalidateTags() has been called with any of the entry's tags.
if ($cache->checksum_invalidations != $checksum['invalidations']) { if ($cache->checksum_invalidations != $checksum['invalidations']) {
...@@ -140,7 +140,7 @@ protected function prepareItem($cache, $allow_invalid) { ...@@ -140,7 +140,7 @@ protected function prepareItem($cache, $allow_invalid) {
/** /**
* Implements Drupal\Core\Cache\CacheBackendInterface::set(). * Implements Drupal\Core\Cache\CacheBackendInterface::set().
*/ */
public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) { public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) {
$try_again = FALSE; $try_again = FALSE;
try { try {
// The bin might not yet exist. // The bin might not yet exist.
...@@ -312,7 +312,7 @@ public function invalidateAll() { ...@@ -312,7 +312,7 @@ public function invalidateAll() {
public function garbageCollection() { public function garbageCollection() {
try { try {
Database::getConnection()->delete($this->bin) Database::getConnection()->delete($this->bin)
->condition('expire', CacheBackendInterface::CACHE_PERMANENT, '<>') ->condition('expire', Cache::PERMANENT, '<>')
->condition('expire', REQUEST_TIME, '<') ->condition('expire', REQUEST_TIME, '<')
->execute(); ->execute();
} }
......
...@@ -83,7 +83,7 @@ protected function prepareItem($cache, $allow_invalid) { ...@@ -83,7 +83,7 @@ protected function prepareItem($cache, $allow_invalid) {
} }
// Check expire time. // Check expire time.
$cache->valid = $cache->expire == CacheBackendInterface::CACHE_PERMANENT || $cache->expire >= REQUEST_TIME; $cache->valid = $cache->expire == Cache::PERMANENT || $cache->expire >= REQUEST_TIME;
if (!$allow_invalid && !$cache->valid) { if (!$allow_invalid && !$cache->valid) {
return FALSE; return FALSE;
...@@ -95,7 +95,7 @@ protected function prepareItem($cache, $allow_invalid) { ...@@ -95,7 +95,7 @@ protected function prepareItem($cache, $allow_invalid) {
/** /**
* Implements Drupal\Core\Cache\CacheBackendInterface::set(). * Implements Drupal\Core\Cache\CacheBackendInterface::set().
*/ */
public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) { public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) {
$this->cache[$cid] = (object) array( $this->cache[$cid] = (object) array(
'cid' => $cid, 'cid' => $cid,
'data' => $data, 'data' => $data,
......
...@@ -36,7 +36,7 @@ public function get($cid, $allow_invalid = FALSE) { ...@@ -36,7 +36,7 @@ public function get($cid, $allow_invalid = FALSE) {
/** /**
* Implements \Drupal\Core\Cache\CacheBackendInterface::set(). * Implements \Drupal\Core\Cache\CacheBackendInterface::set().
*/ */
public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) { public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) {
$this->increaseCounter(__FUNCTION__, $cid); $this->increaseCounter(__FUNCTION__, $cid);
parent::set($cid, $data, $expire, $tags); parent::set($cid, $data, $expire, $tags);
} }
......
...@@ -45,7 +45,7 @@ public function getMultiple(&$cids, $allow_invalid = FALSE) { ...@@ -45,7 +45,7 @@ public function getMultiple(&$cids, $allow_invalid = FALSE) {
/** /**
* Implements Drupal\Core\Cache\CacheBackendInterface::set(). * Implements Drupal\Core\Cache\CacheBackendInterface::set().
*/ */
public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) {} public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) {}
/** /**
* Implements Drupal\Core\Cache\CacheBackendInterface::delete(). * Implements Drupal\Core\Cache\CacheBackendInterface::delete().
......
...@@ -77,7 +77,7 @@ public function read($name) { ...@@ -77,7 +77,7 @@ public function read($name) {
// Read from the storage on a cache miss and cache the data, if any. // Read from the storage on a cache miss and cache the data, if any.
$data = $this->storage->read($name); $data = $this->storage->read($name);
if ($data !== FALSE) { if ($data !== FALSE) {
$this->cache->set($name, $data, CacheBackendInterface::CACHE_PERMANENT); $this->cache->set($name, $data, Cache::PERMANENT);
} }
// If the cache contained bogus data and there is no data in the storage, // If the cache contained bogus data and there is no data in the storage,
// wipe the cache entry. // wipe the cache entry.
...@@ -101,7 +101,7 @@ public function readMultiple(array $names) { ...@@ -101,7 +101,7 @@ public function readMultiple(array $names) {
$list = $this->storage->readMultiple($names); $list = $this->storage->readMultiple($names);
// Cache configuration objects that were loaded from the storage. // Cache configuration objects that were loaded from the storage.
foreach ($list as $name => $data) { foreach ($list as $name => $data) {
$this->cache->set($name, $data, CacheBackendInterface::CACHE_PERMANENT); $this->cache->set($name, $data, Cache::PERMANENT);
} }
} }
...@@ -120,7 +120,7 @@ public function write($name, array $data) { ...@@ -120,7 +120,7 @@ public function write($name, array $data) {
if ($this->storage->write($name, $data)) { if ($this->storage->write($name, $data)) {
// While not all written data is read back, setting the cache instead of // While not all written data is read back, setting the cache instead of
// just deleting it avoids cache rebuild stampedes. // just deleting it avoids cache rebuild stampedes.
$this->cache->set($name, $data, CacheBackendInterface::CACHE_PERMANENT); $this->cache->set($name, $data, Cache::PERMANENT);
Cache::deleteTags(array($this::FIND_BY_PREFIX_CACHE_TAG => TRUE)); Cache::deleteTags(array($this::FIND_BY_PREFIX_CACHE_TAG => TRUE));
$this->findByPrefixCache = array(); $this->findByPrefixCache = array();
return TRUE; return TRUE;
...@@ -212,7 +212,7 @@ protected function findByPrefix($prefix) { ...@@ -212,7 +212,7 @@ protected function findByPrefix($prefix) {
$this->cache->set( $this->cache->set(
'find:' . $prefix, 'find:' . $prefix,
$this->findByPrefixCache[$prefix], $this->findByPrefixCache[$prefix],
CacheBackendInterface::CACHE_PERMANENT, Cache::PERMANENT,
array($this::FIND_BY_PREFIX_CACHE_TAG => TRUE) array($this::FIND_BY_PREFIX_CACHE_TAG => TRUE)
); );
} }
......
...@@ -145,7 +145,8 @@ public function __construct(\Traversable $namespaces, ContainerInterface $contai ...@@ -145,7 +145,8 @@ public function __construct(\Traversable $namespaces, ContainerInterface $contai
$this->discovery = new AnnotatedClassDiscovery('Entity', $namespaces, 'Drupal\Core\Entity\Annotation\EntityType'); $this->discovery = new AnnotatedClassDiscovery('Entity', $namespaces, 'Drupal\Core\Entity\Annotation\EntityType');
$this->discovery = new InfoHookDecorator($this->discovery, 'entity_info'); $this->discovery = new InfoHookDecorator($this->discovery, 'entity_info');
$this->discovery = new AlterDecorator($this->discovery, 'entity_info'); $this->discovery = new AlterDecorator($this->discovery, 'entity_info');
$this->discovery = new CacheDecorator($this->discovery, 'entity_info:' . $this->languageManager->getCurrentLanguage()->id, 'cache', CacheBackendInterface::CACHE_PERMANENT, array('entity_info' => TRUE)); $this->discovery = new CacheDecorator($this->discovery, 'entity_info:' . $this->languageManager->getCurrentLanguage()->id, 'cache', Cache::PERMANENT, array('entity_info' => TRUE));
$this->container = $container; $this->container = $container;
} }
...@@ -363,7 +364,7 @@ public function getFieldDefinitions($entity_type, $bundle = NULL) { ...@@ -363,7 +364,7 @@ public function getFieldDefinitions($entity_type, $bundle = NULL) {
} }
} }
$this->cache->set($cid, $this->entityFieldInfo[$entity_type], CacheBackendInterface::CACHE_PERMANENT, array('entity_info' => TRUE, 'entity_field_info' => TRUE)); $this->cache->set($cid, $this->entityFieldInfo[$entity_type], Cache::PERMANENT, array('entity_info' => TRUE, 'entity_field_info' => TRUE));
} }
} }
...@@ -425,7 +426,7 @@ public function getAllBundleInfo() { ...@@ -425,7 +426,7 @@ public function getAllBundleInfo() {
} }
} }
$this->moduleHandler->alter('entity_bundle_info', $this->bundleInfo); $this->moduleHandler->alter('entity_bundle_info', $this->bundleInfo);
$this->cache->set("entity_bundle_info:$langcode", $this->bundleInfo, CacheBackendInterface::CACHE_PERMANENT, array('entity_info' => TRUE)); $this->cache->set("entity_bundle_info:$langcode", $this->bundleInfo, Cache::PERMANENT, array('entity_info' => TRUE));
} }
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
use Drupal\Component\Plugin\Exception\PluginException; use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\Core\Access\AccessManager; use Drupal\Core\Access\AccessManager;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Controller\ControllerResolverInterface; use Drupal\Core\Controller\ControllerResolverInterface;
use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleHandlerInterface;
...@@ -220,7 +221,7 @@ public function getLocalTasksForRoute($route_name) { ...@@ -220,7 +221,7 @@ public function getLocalTasksForRoute($route_name) {
'parents' => $parents, 'parents' => $parents,
'children' => $children, 'children' => $children,
); );
$this->cacheBackend->set($this->cacheKey . ':' . $route_name, $data, CacheBackendInterface::CACHE_PERMANENT, $this->cacheTags); $this->cacheBackend->set($this->cacheKey . ':' . $route_name, $data, Cache::PERMANENT, $this->cacheTags);
} }
// Create a plugin instance for each element of the hierarchy. // Create a plugin instance for each element of the hierarchy.
foreach ($base_routes as $base_route) { foreach ($base_routes as $base_route) {
......
...@@ -8,11 +8,11 @@ ...@@ -8,11 +8,11 @@
namespace Drupal\Core\Plugin; namespace Drupal\Core\Plugin;
use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface; use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Plugin\Discovery\ContainerDerivativeDiscoveryDecorator; use Drupal\Core\Plugin\Discovery\ContainerDerivativeDiscoveryDecorator;
use Drupal\Component\Plugin\PluginManagerBase; use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\PluginManagerInterface; use Drupal\Component\Plugin\PluginManagerInterface;
use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Language\LanguageManagerInterface;
...@@ -234,7 +234,7 @@ protected function getCachedDefinitions() { ...@@ -234,7 +234,7 @@ protected function getCachedDefinitions() {
*/ */
protected function setCachedDefinitions($definitions) { protected function setCachedDefinitions($definitions) {
if ($this->cacheBackend) { if ($this->cacheBackend) {
$this->cacheBackend->set($this->cacheKey, $definitions, CacheBackendInterface::CACHE_PERMANENT, $this->cacheTags); $this->cacheBackend->set($this->cacheKey, $definitions, Cache::PERMANENT, $this->cacheTags);
} }
$this->definitions = $definitions; $this->definitions = $definitions;
} }
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface; use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface; use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface;
/** /**
* Enables static and persistent caching of discovered plugin definitions. * Enables static and persistent caching of discovered plugin definitions.
...@@ -76,7 +75,7 @@ class CacheDecorator implements CachedDiscoveryInterface { ...@@ -76,7 +75,7 @@ class CacheDecorator implements CachedDiscoveryInterface {
* @param array $cache_tags * @param array $cache_tags
* The cache tags associated with the definition list. * The cache tags associated with the definition list.
*/ */
public function __construct(DiscoveryInterface $decorated, $cache_key, $cache_bin = 'cache', $cache_expire = CacheBackendInterface::CACHE_PERMANENT, array $cache_tags = array()) { public function __construct(DiscoveryInterface $decorated, $cache_key, $cache_bin = 'cache', $cache_expire = Cache::PERMANENT, array $cache_tags = array()) {
$this->decorated = $decorated; $this->decorated = $decorated;
$this->cacheKey = $cache_key; $this->cacheKey = $cache_key;
$this->cacheBin = $cache_bin; $this->cacheBin = $cache_bin;
......
...@@ -239,7 +239,7 @@ public function getRuntime() { ...@@ -239,7 +239,7 @@ public function getRuntime() {
* Persists the theme registry in the cache backend. * Persists the theme registry in the cache backend.
*/ */
protected function setCache() { protected function setCache() {
$this->cache->set('theme_registry:' . $this->theme->name, $this->registry, CacheBackendInterface::CACHE_PERMANENT, array('theme_registry' => TRUE)); $this->cache->set('theme_registry:' . $this->theme->name, $this->registry, Cache::PERMANENT, array('theme_registry' => TRUE));
} }
/** /**
...@@ -312,7 +312,7 @@ protected function build() { ...@@ -312,7 +312,7 @@ protected function build() {
} }
// Only cache this registry if all modules are loaded. // Only cache this registry if all modules are loaded.
if ($this->moduleHandler->isLoaded()) { if ($this->moduleHandler->isLoaded()) {
$this->cache->set("theme_registry:build:modules", $cache, CacheBackendInterface::CACHE_PERMANENT, array('theme_registry' => TRUE)); $this->cache->set("theme_registry:build:modules", $cache, Cache::PERMANENT, array('theme_registry' => TRUE));
} }
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
namespace Drupal\Core\Utility; namespace Drupal\Core\Utility;
use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\Cache;
/** /**
* Provides a caching wrapper to be used in place of large array structures. * Provides a caching wrapper to be used in place of large array structures.
...@@ -205,7 +205,7 @@ protected function set($data, $lock = TRUE) { ...@@ -205,7 +205,7 @@ protected function set($data, $lock = TRUE) {
if ($cached = cache($this->bin)->get($this->cid)) { if ($cached = cache($this->bin)->get($this->cid)) {
$data = $cached->data + $data; $data = $cached->data + $data;
} }
cache($this->bin)->set($this->cid, $data, CacheBackendInterface::CACHE_PERMANENT, $this->tags); cache($this->bin)->set($this->cid, $data, Cache::PERMANENT, $this->tags);
if ($lock) { if ($lock) {
lock()->release($lock_name); lock()->release($lock_name);
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
namespace Drupal\Core\Utility; namespace Drupal\Core\Utility;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Cache\CacheCollector; use Drupal\Core\Cache\CacheCollector;
use Drupal\Core\DestructableInterface; use Drupal\Core\DestructableInterface;
...@@ -162,7 +163,7 @@ protected function updateCache($lock = TRUE) { ...@@ -162,7 +163,7 @@ protected function updateCache($lock = TRUE) {
$registry = $this->initializeRegistry(); $registry = $this->initializeRegistry();
$data = array_merge($registry, $data); $data = array_merge($registry, $data);
} }
$this->cache->set($this->cid, $data, CacheBackendInterface::CACHE_PERMANENT, $this->tags); $this->cache->set($this->cid, $data, Cache::PERMANENT, $this->tags);
if ($lock) { if ($lock) {
$this->lock->release($lock_name); $this->lock->release($lock_name);
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
namespace Drupal\book; namespace Drupal\book;
use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\Cache;
use Drupal\Core\Database\Connection; use Drupal\Core\Database\Connection;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityManagerInterface;
...@@ -589,7 +589,7 @@ public function bookTreeAllData($menu_name, $link = NULL, $max_depth = NULL) { ...@@ -589,7 +589,7 @@ public function bookTreeAllData($menu_name, $link = NULL, $max_depth = NULL) {
} }
// Cache the tree building parameters using the page-specific cid. // Cache the tree building parameters using the page-specific cid.
cache('menu')->set($cid, $tree_parameters, CacheBackendInterface::CACHE_PERMANENT, array('menu' => $menu_name)); cache('menu')->set($cid, $tree_parameters, Cache::PERMANENT, array('menu' => $menu_name));
} }
// Build the tree using the parameters; the resulting tree will be cached // Build the tree using the parameters; the resulting tree will be cached
...@@ -776,7 +776,7 @@ protected function _menu_build_tree($menu_name, array $parameters = array()) { ...@@ -776,7 +776,7 @@ protected function _menu_build_tree($menu_name, array $parameters = array()) {
$this->bookTreeCollectNodeLinks($data['tree'], $data['node_links']); $this->bookTreeCollectNodeLinks($data['tree'], $data['node_links']);
// Cache the data, if it is not already in the cache. // Cache the data, if it is not already in the cache.
cache('menu')->set($tree_cid, $data, CacheBackendInterface::CACHE_PERMANENT, array('menu' => $menu_name)); cache('menu')->set($tree_cid, $data, Cache::PERMANENT, array('menu' => $menu_name));
$trees[$tree_cid] = $data; $trees[$tree_cid] = $data;
} }
......
...@@ -209,7 +209,7 @@ public function getFieldMap() { ...@@ -209,7 +209,7 @@ public function getFieldMap() {
// Save in "static" and persistent caches. // Save in "static" and persistent caches.
$this->fieldMap = $map; $this->fieldMap = $map;
$this->cacheBackend->set('field_info:field_map', $map, CacheBackendInterface::CACHE_PERMANENT, array('field_info' => TRUE)); $this->cacheBackend->set('field_info:field_map', $map, Cache::PERMANENT, array('field_info' => TRUE));
return $map; return $map;
} }
...@@ -237,7 +237,7 @@ public function getFields() { ...@@ -237,7 +237,7 @@ public function getFields() {
} }
// Store in persistent cache. // Store in persistent cache.
$this->cacheBackend->set('field_info:fields', $this->fieldsById, CacheBackendInterface::CACHE_PERMANENT, array('field_info' => TRUE)); $this->cacheBackend->set('field_info:fields', $this->fieldsById, Cache::PERMANENT, array('field_info' => TRUE));
} }
// Fill the name/ID map. // Fill the name/ID map.
...@@ -284,7 +284,7 @@ public function getInstances($entity_type = NULL) { ...@@ -284,7 +284,7 @@ public function getInstances($entity_type = NULL) {
} }
// Store in persistent cache. // Store in persistent cache.
$this->cacheBackend->set('field_info:instances', $this->bundleInstances, CacheBackendInterface::CACHE_PERMANENT, array('field_info' => TRUE)); $this->cacheBackend->set('field_info:instances', $this->bundleInstances, Cache::PERMANENT, array('field_info' => TRUE));
} }
$this->loadedAllInstances = TRUE; $this->loadedAllInstances = TRUE;
...@@ -486,8 +486,8 @@ public function getBundleInstances($entity_type, $bundle) { ...@@ -486,8 +486,8 @@ public function getBundleInstances($entity_type, $bundle) {
// Store in the persistent cache. Fields and instances are cached in // Store in the persistent cache. Fields and instances are cached in
// separate entries because they need to be unserialized separately. // separate entries because they need to be unserialized separately.
$this->cacheBackend->set("field_info:bundle:fields:$entity_type:$bundle", $fields, CacheBackendInterface::CACHE_PERMANENT, array('field_info' => TRUE)); $this->cacheBackend->set("field_info:bundle:fields:$entity_type:$bundle", $fields, Cache::PERMANENT, array('field_info' => TRUE));