From b8ef75c5f48a84bdada9f5f82c0bd0512c3f66a3 Mon Sep 17 00:00:00 2001
From: webchick <webchick@24967.no-reply.drupal.org>
Date: Sat, 25 Jan 2014 21:21:53 -0800
Subject: [PATCH] Issue #2169447 by damiankloip, sun, longwave: DX: Supply
 CacheBackendInterface::CACHE_PERMANENT as Cache::PERMANENT.

---
 core/includes/common.inc                      |  7 ++--
 core/includes/entity.inc                      |  6 +--
 core/includes/menu.inc                        |  7 ++--
 core/includes/schema.inc                      |  3 +-
 core/lib/Drupal/Core/Cache/BackendChain.php   |  2 +-
 core/lib/Drupal/Core/Cache/Cache.php          |  5 +++
 .../Core/Cache/CacheBackendInterface.php      |  2 +-
 core/lib/Drupal/Core/Cache/CacheCollector.php |  3 +-
 .../lib/Drupal/Core/Cache/DatabaseBackend.php |  6 +--
 core/lib/Drupal/Core/Cache/MemoryBackend.php  |  4 +-
 .../Core/Cache/MemoryCounterBackend.php       |  2 +-
 core/lib/Drupal/Core/Cache/NullBackend.php    |  2 +-
 core/lib/Drupal/Core/Config/CachedStorage.php |  8 ++--
 core/lib/Drupal/Core/Entity/EntityManager.php |  7 ++--
 .../lib/Drupal/Core/Menu/LocalTaskManager.php |  3 +-
 .../Core/Plugin/DefaultPluginManager.php      |  4 +-
 .../Core/Plugin/Discovery/CacheDecorator.php  |  3 +-
 core/lib/Drupal/Core/Theme/Registry.php       |  4 +-
 core/lib/Drupal/Core/Utility/CacheArray.php   |  4 +-
 .../lib/Drupal/Core/Utility/ThemeRegistry.php |  3 +-
 .../book/lib/Drupal/book/BookManager.php      |  6 +--
 .../field/lib/Drupal/field/FieldInfo.php      | 12 +++---
 core/modules/filter/filter.module             |  5 +--
 core/modules/node/node.module                 |  4 +-
 .../rest/LinkManager/RelationLinkManager.php  |  3 +-
 .../rest/LinkManager/TypeLinkManager.php      |  3 +-
 .../Cache/GenericCacheBackendUnitTestBase.php | 42 +++++++++----------
 core/modules/toolbar/toolbar.module           |  3 +-
 .../user/lib/Drupal/user/PermissionsHash.php  |  3 +-
 .../Plugin/views/cache/CachePluginBase.php    |  3 +-
 .../Drupal/views/Plugin/views/cache/Time.php  |  4 +-
 .../BackendChainImplementationUnitTest.php    | 18 ++++----
 .../Tests/Core/Cache/CacheCollectorTest.php   |  8 ++--
 .../Tests/Core/Menu/LocalTaskManagerTest.php  |  6 +--
 34 files changed, 104 insertions(+), 101 deletions(-)

diff --git a/core/includes/common.inc b/core/includes/common.inc
index 7c1b256c0603..8eec0acf0641 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -15,7 +15,6 @@
 use Drupal\Component\PhpStorage\PhpStorageFactory;
 use Drupal\Component\Utility\MapArray;
 use Drupal\Component\Utility\NestedArray;
-use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\Core\Datetime\DrupalDateTime;
 use Drupal\Core\Routing\GeneratorNotInitializedException;
 use Drupal\Core\SystemListingInfo;
@@ -3149,7 +3148,7 @@ function drupal_page_set_cache(Response $response, Request $request) {
         'page_compressed' => $page_compressed,
       ),
       'tags' => array('content' => TRUE) + drupal_cache_tags_page_get(),
-      'expire' => CacheBackendInterface::CACHE_PERMANENT,
+      'expire' => Cache::PERMANENT,
       'created' => REQUEST_TIME,
     );
 
@@ -4103,7 +4102,7 @@ function drupal_render_cache_set(&$markup, array $elements) {
   }
 
   $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);
   cache($bin)->set($cid, $data, $expire, $tags);
 }
@@ -4418,7 +4417,7 @@ function drupal_cache_tags_page_get() {
  *   - #pre_render: $function with a _pre_render suffix.
  *   - #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));
   $query->preExecute();
   $cache_keys[] = hash('sha256', serialize(array((string) $query, $query->getArguments())));
diff --git a/core/includes/entity.inc b/core/includes/entity.inc
index 964a7beadd5a..5b7cb3fbe8ce 100644
--- a/core/includes/entity.inc
+++ b/core/includes/entity.inc
@@ -5,7 +5,7 @@
  * 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\EntityInterface;
 use Drupal\Core\Language\Language;
@@ -131,7 +131,7 @@ function entity_get_form_modes($entity_type = NULL) {
         $form_modes[$form_mode_entity_type][$form_mode_name] = (array) $form_mode;
       }
       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) {
         $view_modes[$view_mode_entity_type][$view_mode_name] = (array) $view_mode;
       }
       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));
     }
   }
 
diff --git a/core/includes/menu.inc b/core/includes/menu.inc
index ca3ed515d6a0..c959a72f47af 100644
--- a/core/includes/menu.inc
+++ b/core/includes/menu.inc
@@ -8,7 +8,6 @@
 use Drupal\Component\Utility\NestedArray;
 use Drupal\Component\Utility\String;
 use Drupal\Core\Cache\Cache;
-use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\Core\Language\Language;
 use Drupal\Core\Routing\RequestHelper;
 use Drupal\Core\Template\Attribute;
@@ -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('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
@@ -1402,7 +1401,7 @@ function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail =
           $tree_parameters['active_trail'] = $active_trail;
         }
         // 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
@@ -1513,7 +1512,7 @@ function _menu_build_tree($menu_name, array $parameters = array()) {
     menu_tree_collect_node_links($data['tree'], $data['node_links']);
 
     // 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;
   }
 
diff --git a/core/includes/schema.inc b/core/includes/schema.inc
index 83ce4838f8e3..e086da7c7e39 100644
--- a/core/includes/schema.inc
+++ b/core/includes/schema.inc
@@ -6,7 +6,6 @@
  */
 
 use Drupal\Core\Cache\Cache;
-use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\Core\Database\Database;
 use Drupal\Core\Utility\SchemaCache;
 
@@ -100,7 +99,7 @@ function drupal_get_complete_schema($rebuild = FALSE) {
       // If the schema is empty, avoid saving it: some database engines require
       // the schema to perform queries, and this could lead to infinite loops.
       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));
       }
     }
   }
diff --git a/core/lib/Drupal/Core/Cache/BackendChain.php b/core/lib/Drupal/Core/Cache/BackendChain.php
index f4b2933dc8a9..5a20ff69c2d8 100644
--- a/core/lib/Drupal/Core/Cache/BackendChain.php
+++ b/core/lib/Drupal/Core/Cache/BackendChain.php
@@ -123,7 +123,7 @@ public function getMultiple(&$cids, $allow_invalid = FALSE) {
   /**
    * 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) {
       $backend->set($cid, $data, $expire, $tags);
     }
diff --git a/core/lib/Drupal/Core/Cache/Cache.php b/core/lib/Drupal/Core/Cache/Cache.php
index a92a27e86ae2..c2f5fe66ddd9 100644
--- a/core/lib/Drupal/Core/Cache/Cache.php
+++ b/core/lib/Drupal/Core/Cache/Cache.php
@@ -12,6 +12,11 @@
  */
 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.
    *
diff --git a/core/lib/Drupal/Core/Cache/CacheBackendInterface.php b/core/lib/Drupal/Core/Cache/CacheBackendInterface.php
index 7bb24d649ac2..00469182cf8e 100644
--- a/core/lib/Drupal/Core/Cache/CacheBackendInterface.php
+++ b/core/lib/Drupal/Core/Cache/CacheBackendInterface.php
@@ -146,7 +146,7 @@ public function getMultiple(&$cids, $allow_invalid = FALSE);
    * @see \Drupal\Core\Cache\CacheBackendInterface::get()
    * @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.
diff --git a/core/lib/Drupal/Core/Cache/CacheCollector.php b/core/lib/Drupal/Core/Cache/CacheCollector.php
index aa1fff22e165..5971cf179244 100644
--- a/core/lib/Drupal/Core/Cache/CacheCollector.php
+++ b/core/lib/Drupal/Core/Cache/CacheCollector.php
@@ -7,7 +7,6 @@
 
 namespace Drupal\Core\Cache;
 
-use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\Core\DestructableInterface;
 use Drupal\Core\Lock\LockBackendInterface;
 
@@ -242,7 +241,7 @@ protected function updateCache($lock = TRUE) {
       foreach ($this->keysToRemove as $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) {
         $this->lock->release($lock_name);
       }
diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php
index 34654039705a..5d6362e1fe4a 100644
--- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php
+++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php
@@ -118,7 +118,7 @@ protected function prepareItem($cache, $allow_invalid) {
     }
 
     // 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.
     if ($cache->checksum_invalidations != $checksum['invalidations']) {
@@ -140,7 +140,7 @@ protected function prepareItem($cache, $allow_invalid) {
   /**
    * 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 {
       // The bin might not yet exist.
@@ -312,7 +312,7 @@ public function invalidateAll() {
   public function garbageCollection() {
     try {
       Database::getConnection()->delete($this->bin)
-        ->condition('expire', CacheBackendInterface::CACHE_PERMANENT, '<>')
+        ->condition('expire', Cache::PERMANENT, '<>')
         ->condition('expire', REQUEST_TIME, '<')
         ->execute();
     }
diff --git a/core/lib/Drupal/Core/Cache/MemoryBackend.php b/core/lib/Drupal/Core/Cache/MemoryBackend.php
index 7ce26b9aab1c..a7faca6372af 100644
--- a/core/lib/Drupal/Core/Cache/MemoryBackend.php
+++ b/core/lib/Drupal/Core/Cache/MemoryBackend.php
@@ -83,7 +83,7 @@ protected function prepareItem($cache, $allow_invalid) {
     }
 
     // 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) {
       return FALSE;
@@ -95,7 +95,7 @@ protected function prepareItem($cache, $allow_invalid) {
   /**
    * 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(
       'cid' => $cid,
       'data' => $data,
diff --git a/core/lib/Drupal/Core/Cache/MemoryCounterBackend.php b/core/lib/Drupal/Core/Cache/MemoryCounterBackend.php
index b028ea08a865..65950bf1db47 100644
--- a/core/lib/Drupal/Core/Cache/MemoryCounterBackend.php
+++ b/core/lib/Drupal/Core/Cache/MemoryCounterBackend.php
@@ -36,7 +36,7 @@ public function get($cid, $allow_invalid = FALSE) {
   /**
    * 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);
     parent::set($cid, $data, $expire, $tags);
   }
diff --git a/core/lib/Drupal/Core/Cache/NullBackend.php b/core/lib/Drupal/Core/Cache/NullBackend.php
index 127101aea1f6..0364663e6f71 100644
--- a/core/lib/Drupal/Core/Cache/NullBackend.php
+++ b/core/lib/Drupal/Core/Cache/NullBackend.php
@@ -45,7 +45,7 @@ public function getMultiple(&$cids, $allow_invalid = FALSE) {
   /**
    * 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().
diff --git a/core/lib/Drupal/Core/Config/CachedStorage.php b/core/lib/Drupal/Core/Config/CachedStorage.php
index beb8c09a1d6a..e3f1c2b34c5a 100644
--- a/core/lib/Drupal/Core/Config/CachedStorage.php
+++ b/core/lib/Drupal/Core/Config/CachedStorage.php
@@ -77,7 +77,7 @@ public function read($name) {
     // Read from the storage on a cache miss and cache the data, if any.
     $data = $this->storage->read($name);
     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,
     // wipe the cache entry.
@@ -101,7 +101,7 @@ public function readMultiple(array $names) {
       $list = $this->storage->readMultiple($names);
       // Cache configuration objects that were loaded from the storage.
       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) {
     if ($this->storage->write($name, $data)) {
       // While not all written data is read back, setting the cache instead of
       // 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));
       $this->findByPrefixCache = array();
       return TRUE;
@@ -212,7 +212,7 @@ protected function findByPrefix($prefix) {
         $this->cache->set(
           'find:' . $prefix,
           $this->findByPrefixCache[$prefix],
-          CacheBackendInterface::CACHE_PERMANENT,
+          Cache::PERMANENT,
           array($this::FIND_BY_PREFIX_CACHE_TAG => TRUE)
         );
       }
diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php
index 6221633ec46f..329131b1f381 100644
--- a/core/lib/Drupal/Core/Entity/EntityManager.php
+++ b/core/lib/Drupal/Core/Entity/EntityManager.php
@@ -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 InfoHookDecorator($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;
   }
 
@@ -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() {
           }
         }
         $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));
       }
     }
 
diff --git a/core/lib/Drupal/Core/Menu/LocalTaskManager.php b/core/lib/Drupal/Core/Menu/LocalTaskManager.php
index 2649aa7db09a..a436d57424f3 100644
--- a/core/lib/Drupal/Core/Menu/LocalTaskManager.php
+++ b/core/lib/Drupal/Core/Menu/LocalTaskManager.php
@@ -9,6 +9,7 @@
 
 use Drupal\Component\Plugin\Exception\PluginException;
 use Drupal\Core\Access\AccessManager;
+use Drupal\Core\Cache\Cache;
 use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\Core\Controller\ControllerResolverInterface;
 use Drupal\Core\Extension\ModuleHandlerInterface;
@@ -220,7 +221,7 @@ public function getLocalTasksForRoute($route_name) {
           'parents' => $parents,
           '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.
       foreach ($base_routes as $base_route) {
diff --git a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php
index da6fb437c63c..6cbabf8989c4 100644
--- a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php
+++ b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php
@@ -8,11 +8,11 @@
 namespace Drupal\Core\Plugin;
 
 use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface;
-use Drupal\Core\Cache\Cache;
 use Drupal\Core\Plugin\Discovery\ContainerDerivativeDiscoveryDecorator;
 use Drupal\Component\Plugin\PluginManagerBase;
 use Drupal\Component\Plugin\PluginManagerInterface;
 use Drupal\Component\Utility\NestedArray;
+use Drupal\Core\Cache\Cache;
 use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\Core\Extension\ModuleHandlerInterface;
 use Drupal\Core\Language\LanguageManagerInterface;
@@ -234,7 +234,7 @@ protected function getCachedDefinitions() {
    */
   protected function setCachedDefinitions($definitions) {
     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;
   }
diff --git a/core/lib/Drupal/Core/Plugin/Discovery/CacheDecorator.php b/core/lib/Drupal/Core/Plugin/Discovery/CacheDecorator.php
index f5d9a8446689..9d3cc9aa116e 100644
--- a/core/lib/Drupal/Core/Plugin/Discovery/CacheDecorator.php
+++ b/core/lib/Drupal/Core/Plugin/Discovery/CacheDecorator.php
@@ -10,7 +10,6 @@
 use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface;
 use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
 use Drupal\Core\Cache\Cache;
-use Drupal\Core\Cache\CacheBackendInterface;
 
 /**
  * Enables static and persistent caching of discovered plugin definitions.
@@ -76,7 +75,7 @@ class CacheDecorator implements CachedDiscoveryInterface {
    * @param array $cache_tags
    *   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->cacheKey = $cache_key;
     $this->cacheBin = $cache_bin;
diff --git a/core/lib/Drupal/Core/Theme/Registry.php b/core/lib/Drupal/Core/Theme/Registry.php
index cbe6643928d9..b0fed73c205d 100644
--- a/core/lib/Drupal/Core/Theme/Registry.php
+++ b/core/lib/Drupal/Core/Theme/Registry.php
@@ -239,7 +239,7 @@ public function getRuntime() {
    * Persists the theme registry in the cache backend.
    */
   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() {
       }
       // Only cache this registry if all modules are loaded.
       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));
       }
     }
 
diff --git a/core/lib/Drupal/Core/Utility/CacheArray.php b/core/lib/Drupal/Core/Utility/CacheArray.php
index b3fa316bdcea..2323756d90cc 100644
--- a/core/lib/Drupal/Core/Utility/CacheArray.php
+++ b/core/lib/Drupal/Core/Utility/CacheArray.php
@@ -7,7 +7,7 @@
 
 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.
@@ -205,7 +205,7 @@ protected function set($data, $lock = TRUE) {
       if ($cached = cache($this->bin)->get($this->cid)) {
         $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) {
         lock()->release($lock_name);
       }
diff --git a/core/lib/Drupal/Core/Utility/ThemeRegistry.php b/core/lib/Drupal/Core/Utility/ThemeRegistry.php
index 0979e07f0810..8d3e1f88d6c8 100644
--- a/core/lib/Drupal/Core/Utility/ThemeRegistry.php
+++ b/core/lib/Drupal/Core/Utility/ThemeRegistry.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\Core\Utility;
 
+use Drupal\Core\Cache\Cache;
 use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\Core\Cache\CacheCollector;
 use Drupal\Core\DestructableInterface;
@@ -162,7 +163,7 @@ protected function updateCache($lock = TRUE) {
         $registry = $this->initializeRegistry();
         $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) {
         $this->lock->release($lock_name);
       }
diff --git a/core/modules/book/lib/Drupal/book/BookManager.php b/core/modules/book/lib/Drupal/book/BookManager.php
index 9b415a8d017f..d4259f07404a 100644
--- a/core/modules/book/lib/Drupal/book/BookManager.php
+++ b/core/modules/book/lib/Drupal/book/BookManager.php
@@ -6,7 +6,7 @@
 
 namespace Drupal\book;
 
-use Drupal\Core\Cache\CacheBackendInterface;
+use Drupal\Core\Cache\Cache;
 use Drupal\Core\Database\Connection;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Entity\EntityManagerInterface;
@@ -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('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
@@ -776,7 +776,7 @@ protected function _menu_build_tree($menu_name, array $parameters = array()) {
       $this->bookTreeCollectNodeLinks($data['tree'], $data['node_links']);
 
       // 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;
     }
 
diff --git a/core/modules/field/lib/Drupal/field/FieldInfo.php b/core/modules/field/lib/Drupal/field/FieldInfo.php
index e458c0f80438..61663e8b8e42 100644
--- a/core/modules/field/lib/Drupal/field/FieldInfo.php
+++ b/core/modules/field/lib/Drupal/field/FieldInfo.php
@@ -209,7 +209,7 @@ public function getFieldMap() {
 
     // Save in "static" and persistent caches.
     $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;
   }
@@ -237,7 +237,7 @@ public function getFields() {
       }
 
       // 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.
@@ -284,7 +284,7 @@ public function getInstances($entity_type = NULL) {
         }
 
         // 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;
@@ -486,8 +486,8 @@ public function getBundleInstances($entity_type, $bundle) {
 
     // Store in the persistent cache. Fields and instances are cached in
     // 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:instances:$entity_type:$bundle", $instances, CacheBackendInterface::CACHE_PERMANENT, array('field_info' => TRUE));
+    $this->cacheBackend->set("field_info:bundle:fields:$entity_type:$bundle", $fields, Cache::PERMANENT, array('field_info' => TRUE));
+    $this->cacheBackend->set("field_info:bundle:instances:$entity_type:$bundle", $instances, Cache::PERMANENT, array('field_info' => TRUE));
 
     return $instances;
   }
@@ -545,7 +545,7 @@ public function getBundleExtraFields($entity_type, $bundle) {
 
     // Store in the 'static' and persistent caches.
     $this->bundleExtraFields[$entity_type][$bundle] = $info;
-    $this->cacheBackend->set("field_info:bundle_extra:$entity_type:$bundle", $info, CacheBackendInterface::CACHE_PERMANENT, array('field_info' => TRUE));
+    $this->cacheBackend->set("field_info:bundle_extra:$entity_type:$bundle", $info, Cache::PERMANENT, array('field_info' => TRUE));
 
     return $this->bundleExtraFields[$entity_type][$bundle];
   }
diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module
index 7d7efbec756a..1c685f2d1b1a 100644
--- a/core/modules/filter/filter.module
+++ b/core/modules/filter/filter.module
@@ -7,7 +7,6 @@
 
 use Drupal\Component\Utility\String;
 use Drupal\Core\Cache\Cache;
-use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\Core\Language\Language;
 use Drupal\Core\Session\AccountInterface;
 use Drupal\Core\Template\Attribute;
@@ -200,7 +199,7 @@ function filter_formats(AccountInterface $account = NULL) {
     else {
       $formats['all'] = \Drupal::entityManager()->getStorageController('filter_format')->loadByProperties(array('status' => TRUE));
       uasort($formats['all'], 'Drupal\Core\Config\Entity\ConfigEntityBase::sort');
-      \Drupal::cache()->set("filter_formats:{$language_interface->id}", $formats['all'], CacheBackendInterface::CACHE_PERMANENT, array('filter_formats' => TRUE));
+      \Drupal::cache()->set("filter_formats:{$language_interface->id}", $formats['all'], Cache::PERMANENT, array('filter_formats' => TRUE));
     }
   }
 
@@ -638,7 +637,7 @@ function check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE,
   // automatically flushed when the text format is updated.
   // @see \Drupal\filter\Entity\FilterFormat::save()
   if ($cache) {
-    cache('filter')->set($cache_id, $text, CacheBackendInterface::CACHE_PERMANENT, array('filter_format' => $format->id()));
+    cache('filter')->set($cache_id, $text, Cache::PERMANENT, array('filter_format' => $format->id()));
   }
 
   return $text;
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index b457cb9b4914..28ca4f10f945 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -11,7 +11,7 @@
 use Drupal\Component\Utility\String;
 use Drupal\Core\Language\Language;
 use Symfony\Component\HttpFoundation\Response;
-use Drupal\Core\Cache\CacheBackendInterface;
+use Drupal\Core\Cache\Cache;
 use Drupal\Core\Database\Query\AlterableInterface;
 use Drupal\Core\Database\Query\SelectInterface;
 use Drupal\node\NodeTypeInterface;
@@ -342,7 +342,7 @@ function node_type_get_names() {
     $config = \Drupal::config($config_name);
     $names[$config->get('type')] = $config->get('name');
   }
-  cache()->set($cid, $names, CacheBackendInterface::CACHE_PERMANENT, array(
+  cache()->set($cid, $names, Cache::PERMANENT, array(
     'node_type' => array_keys($names),
     'node_types' => TRUE,
   ));
diff --git a/core/modules/rest/lib/Drupal/rest/LinkManager/RelationLinkManager.php b/core/modules/rest/lib/Drupal/rest/LinkManager/RelationLinkManager.php
index 3fd241fecfcc..c6c4028cc279 100644
--- a/core/modules/rest/lib/Drupal/rest/LinkManager/RelationLinkManager.php
+++ b/core/modules/rest/lib/Drupal/rest/LinkManager/RelationLinkManager.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\rest\LinkManager;
 
+use Drupal\Core\Cache\Cache;
 use Drupal\Core\Cache\CacheBackendInterface;
 
 class RelationLinkManager implements RelationLinkManagerInterface{
@@ -88,6 +89,6 @@ protected function writeCache() {
     }
     // These URIs only change when field info changes, so cache it permanently
     // and only clear it when field_info is cleared.
-    $this->cache->set('rest:links:relations', $data, CacheBackendInterface::CACHE_PERMANENT, array('field_info' => TRUE));
+    $this->cache->set('rest:links:relations', $data, Cache::PERMANENT, array('field_info' => TRUE));
   }
 }
diff --git a/core/modules/rest/lib/Drupal/rest/LinkManager/TypeLinkManager.php b/core/modules/rest/lib/Drupal/rest/LinkManager/TypeLinkManager.php
index 7e41aeec64f1..1d76bde4b8e5 100644
--- a/core/modules/rest/lib/Drupal/rest/LinkManager/TypeLinkManager.php
+++ b/core/modules/rest/lib/Drupal/rest/LinkManager/TypeLinkManager.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\rest\LinkManager;
 
+use Drupal\Core\Cache\Cache;
 use Drupal\Core\Cache\CacheBackendInterface;
 
 class TypeLinkManager implements TypeLinkManagerInterface {
@@ -98,6 +99,6 @@ protected function writeCache() {
     }
     // These URIs only change when entity info changes, so cache it permanently
     // and only clear it when entity_info is cleared.
-    $this->cache->set('rest:links:types', $data, CacheBackendInterface::CACHE_PERMANENT, array('entity_info' => TRUE));
+    $this->cache->set('rest:links:types', $data, Cache::PERMANENT, array('entity_info' => TRUE));
   }
 }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Cache/GenericCacheBackendUnitTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Cache/GenericCacheBackendUnitTestBase.php
index e4e884dbeb13..e5588167c10c 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Cache/GenericCacheBackendUnitTestBase.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Cache/GenericCacheBackendUnitTestBase.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\system\Tests\Cache;
 
-use Drupal\Core\Cache\CacheBackendInterface;
+use Drupal\Core\Cache\Cache;
 use Drupal\simpletest\DrupalUnitTestBase;
 
 /**
@@ -141,7 +141,7 @@ public function testSetGet() {
     $this->assertIdentical(7, $cached->data);
     $this->assertTrue($cached->valid, 'Item is marked as valid.');
     $this->assertEqual($cached->created, REQUEST_TIME, 'Created time is correct.');
-    $this->assertEqual($cached->expire, CacheBackendInterface::CACHE_PERMANENT, 'Expire time is correct.');
+    $this->assertEqual($cached->expire, Cache::PERMANENT, 'Expire time is correct.');
 
     $this->assertIdentical(FALSE, $backend->get('test2'), "Backend does not contain data for cache id test2.");
     $backend->set('test2', array('value' => 3), REQUEST_TIME + 3);
@@ -247,7 +247,7 @@ public function testGetMultiple() {
     // Test return - ensure that objects has expected properties.
     $this->assertTrue($ret['test2']->valid, 'Item is marked as valid.');
     $this->assertEqual($ret['test2']->created, REQUEST_TIME, 'Created time is correct.');
-    $this->assertEqual($ret['test2']->expire, CacheBackendInterface::CACHE_PERMANENT, 'Expire time is correct.');
+    $this->assertEqual($ret['test2']->expire, Cache::PERMANENT, 'Expire time is correct.');
     // Test return - ensure it does not contain nonexistent cache ids.
     $this->assertFalse(isset($ret['test19']), "Nonexistent cache id test19 is not set.");
     $this->assertFalse(isset($ret['test21']), "Nonexistent cache id test21 is not set.");
@@ -359,8 +359,8 @@ function testDeleteTags() {
     $backend = $this->getCacheBackend();
 
     // Create two cache entries with the same tag and tag value.
-    $backend->set('test_cid_invalidate1', $this->defaultValue, CacheBackendInterface::CACHE_PERMANENT, array('test_tag' => 2));
-    $backend->set('test_cid_invalidate2', $this->defaultValue, CacheBackendInterface::CACHE_PERMANENT, array('test_tag' => 2));
+    $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, array('test_tag' => 2));
+    $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, array('test_tag' => 2));
     $this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2'), 'Two cache items were created.');
 
     // Delete test_tag of value 1. This should delete both entries.
@@ -369,8 +369,8 @@ function testDeleteTags() {
     $this->assertFalse($backend->get('test_cid_invalidate1', TRUE) || $backend->get('test_cid_invalidate2', TRUE), 'Two cache items deleted after deleting a cache tag.');
 
     // Create two cache entries with the same tag and an array tag value.
-    $backend->set('test_cid_invalidate1', $this->defaultValue, CacheBackendInterface::CACHE_PERMANENT, array('test_tag' => array(1)));
-    $backend->set('test_cid_invalidate2', $this->defaultValue, CacheBackendInterface::CACHE_PERMANENT, array('test_tag' => array(1)));
+    $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, array('test_tag' => array(1)));
+    $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, array('test_tag' => array(1)));
     $this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2'), 'Two cache items were created.');
 
     // Delete test_tag of value 1. This should delete both entries.
@@ -379,9 +379,9 @@ function testDeleteTags() {
     $this->assertFalse($backend->get('test_cid_invalidate1', TRUE) || $backend->get('test_cid_invalidate2', TRUE), 'Two cache items deleted after deleting a cache tag.');
 
     // Create three cache entries with a mix of tags and tag values.
-    $backend->set('test_cid_invalidate1', $this->defaultValue, CacheBackendInterface::CACHE_PERMANENT, array('test_tag' => array(1)));
-    $backend->set('test_cid_invalidate2', $this->defaultValue, CacheBackendInterface::CACHE_PERMANENT, array('test_tag' => array(2)));
-    $backend->set('test_cid_invalidate3', $this->defaultValue, CacheBackendInterface::CACHE_PERMANENT, array('test_tag_foo' => array(3)));
+    $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, array('test_tag' => array(1)));
+    $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, array('test_tag' => array(2)));
+    $backend->set('test_cid_invalidate3', $this->defaultValue, Cache::PERMANENT, array('test_tag_foo' => array(3)));
     $this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2') && $backend->get('test_cid_invalidate3'), 'Three cached items were created.');
     $backend->deleteTags(array('test_tag_foo' => array(3)));
     $this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2'), 'Cached items not matching the tag were not deleted.');
@@ -393,7 +393,7 @@ function testDeleteTags() {
     $tags = array('test_tag' => array(1, 2, 3));
     $bins = array('path', 'bootstrap', 'page');
     foreach ($bins as $bin) {
-      $this->getCacheBackend($bin)->set('test', $this->defaultValue, CacheBackendInterface::CACHE_PERMANENT, $tags);
+      $this->getCacheBackend($bin)->set('test', $this->defaultValue, Cache::PERMANENT, $tags);
       $this->assertTrue($this->getCacheBackend($bin)->get('test'), 'Cache item was set in bin.');
     }
 
@@ -419,7 +419,7 @@ public function testDeleteAll() {
     $backend = $this->getCacheBackend();
 
     // Set both expiring and permanent keys.
-    $backend->set('test1', 1, CacheBackendInterface::CACHE_PERMANENT);
+    $backend->set('test1', 1, Cache::PERMANENT);
     $backend->set('test2', 3, time() + 1000);
 
     $backend->deleteAll();
@@ -466,8 +466,8 @@ function testInvalidateTags() {
     $backend = $this->getCacheBackend();
 
     // Create two cache entries with the same tag and tag value.
-    $backend->set('test_cid_invalidate1', $this->defaultValue, CacheBackendInterface::CACHE_PERMANENT, array('test_tag' => 2));
-    $backend->set('test_cid_invalidate2', $this->defaultValue, CacheBackendInterface::CACHE_PERMANENT, array('test_tag' => 2));
+    $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, array('test_tag' => 2));
+    $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, array('test_tag' => 2));
     $this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2'), 'Two cache items were created.');
 
     // Invalidate test_tag of value 1. This should invalidate both entries.
@@ -476,8 +476,8 @@ function testInvalidateTags() {
     $this->assertTrue($backend->get('test_cid_invalidate1', TRUE) && $backend->get('test_cid_invalidate2', TRUE), 'Cache items not deleted after invalidating a cache tag.');
 
     // Create two cache entries with the same tag and an array tag value.
-    $backend->set('test_cid_invalidate1', $this->defaultValue, CacheBackendInterface::CACHE_PERMANENT, array('test_tag' => array(1)));
-    $backend->set('test_cid_invalidate2', $this->defaultValue, CacheBackendInterface::CACHE_PERMANENT, array('test_tag' => array(1)));
+    $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, array('test_tag' => array(1)));
+    $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, array('test_tag' => array(1)));
     $this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2'), 'Two cache items were created.');
 
     // Invalidate test_tag of value 1. This should invalidate both entries.
@@ -486,9 +486,9 @@ function testInvalidateTags() {
     $this->assertTrue($backend->get('test_cid_invalidate1', TRUE) && $backend->get('test_cid_invalidate2', TRUE), 'Cache items not deleted after invalidating a cache tag.');
 
     // Create three cache entries with a mix of tags and tag values.
-    $backend->set('test_cid_invalidate1', $this->defaultValue, CacheBackendInterface::CACHE_PERMANENT, array('test_tag' => array(1)));
-    $backend->set('test_cid_invalidate2', $this->defaultValue, CacheBackendInterface::CACHE_PERMANENT, array('test_tag' => array(2)));
-    $backend->set('test_cid_invalidate3', $this->defaultValue, CacheBackendInterface::CACHE_PERMANENT, array('test_tag_foo' => array(3)));
+    $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, array('test_tag' => array(1)));
+    $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, array('test_tag' => array(2)));
+    $backend->set('test_cid_invalidate3', $this->defaultValue, Cache::PERMANENT, array('test_tag_foo' => array(3)));
     $this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2') && $backend->get('test_cid_invalidate3'), 'Three cached items were created.');
     $backend->invalidateTags(array('test_tag_foo' => array(3)));
     $this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2'), 'Cache items not matching the tag were not invalidated.');
@@ -500,7 +500,7 @@ function testInvalidateTags() {
     $tags = array('test_tag' => array(1, 2, 3));
     $bins = array('path', 'bootstrap', 'page');
     foreach ($bins as $bin) {
-      $this->getCacheBackend($bin)->set('test', $this->defaultValue, CacheBackendInterface::CACHE_PERMANENT, $tags);
+      $this->getCacheBackend($bin)->set('test', $this->defaultValue, Cache::PERMANENT, $tags);
       $this->assertTrue($this->getCacheBackend($bin)->get('test'), 'Cache item was set in bin.');
     }
 
@@ -526,7 +526,7 @@ public function testInvalidateAll() {
     $backend = $this->getCacheBackend();
 
     // Set both expiring and permanent keys.
-    $backend->set('test1', 1, CacheBackendInterface::CACHE_PERMANENT);
+    $backend->set('test1', 1, Cache::PERMANENT);
     $backend->set('test2', 3, time() + 1000);
 
     $backend->invalidateAll();
diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module
index 86ef5ee5d885..f35d4ae718ad 100644
--- a/core/modules/toolbar/toolbar.module
+++ b/core/modules/toolbar/toolbar.module
@@ -6,7 +6,6 @@
  */
 
 use Drupal\Core\Cache\Cache;
-use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\Core\Language\Language;
 use Drupal\Core\Template\Attribute;
 use Drupal\Component\Utility\Crypt;
@@ -586,7 +585,7 @@ function _toolbar_get_subtrees_hash() {
     // caches later, based on the user's ID regardless of language.
     // Clear the cache when the 'locale' tag is deleted. This ensures a fresh
     // subtrees rendering when string translations are made.
-    cache('toolbar')->set($cid, $hash, CacheBackendInterface::CACHE_PERMANENT, array('user' => array($uid), 'locale' => TRUE,));
+    cache('toolbar')->set($cid, $hash, Cache::PERMANENT, array('user' => array($uid), 'locale' => TRUE,));
   }
   return $hash;
 }
diff --git a/core/modules/user/lib/Drupal/user/PermissionsHash.php b/core/modules/user/lib/Drupal/user/PermissionsHash.php
index 59fea9c45400..3c6fe8754440 100644
--- a/core/modules/user/lib/Drupal/user/PermissionsHash.php
+++ b/core/modules/user/lib/Drupal/user/PermissionsHash.php
@@ -9,6 +9,7 @@
 
 use Drupal\Core\Session\AccountInterface;
 use Drupal\Core\PrivateKey;
+use Drupal\Core\Cache\Cache;
 use Drupal\Core\Cache\CacheBackendInterface;
 
 /**
@@ -57,7 +58,7 @@ public function generate(AccountInterface $account) {
     }
     else {
       $permissions_hash = $this->doGenerate($sorted_roles);
-      $this->cache->set("user_permissions_hash:$role_list", $permissions_hash, CacheBackendInterface::CACHE_PERMANENT, array('role' => $sorted_roles));
+      $this->cache->set("user_permissions_hash:$role_list", $permissions_hash, Cache::PERMANENT, array('role' => $sorted_roles));
     }
 
     return $permissions_hash;
diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php
index e51b1e19c4e7..c07b84607990 100644
--- a/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php
+++ b/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php
@@ -9,7 +9,6 @@
 
 use Drupal\Core\Cache\Cache;
 use Drupal\Core\Language\Language;
-use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\views\Plugin\views\PluginBase;
 use Drupal\Core\Database\Query\Select;
 
@@ -107,7 +106,7 @@ protected function cacheExpire($type) {
     *   The cache type, either 'query', 'result' or 'output'.
     */
   protected function cacheSetExpire($type) {
-    return CacheBackendInterface::CACHE_PERMANENT;
+    return Cache::PERMANENT;
   }
 
   /**
diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/cache/Time.php b/core/modules/views/lib/Drupal/views/Plugin/views/cache/Time.php
index 009a178718b2..3db6bfabb197 100644
--- a/core/modules/views/lib/Drupal/views/Plugin/views/cache/Time.php
+++ b/core/modules/views/lib/Drupal/views/Plugin/views/cache/Time.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\views\Plugin\views\cache;
 
-use Drupal\Core\Cache\CacheBackendInterface;
+use Drupal\Core\Cache\Cache;
 
 /**
  * Simple caching of query results for Views displays.
@@ -122,7 +122,7 @@ protected function cacheSetExpire($type) {
       return time() + $lifespan;
     }
     else {
-      return CacheBackendInterface::CACHE_PERMANENT;
+      return Cache::PERMANENT;
     }
   }
 
diff --git a/core/tests/Drupal/Tests/Core/Cache/BackendChainImplementationUnitTest.php b/core/tests/Drupal/Tests/Core/Cache/BackendChainImplementationUnitTest.php
index cba4c31061c2..75c0a977581d 100644
--- a/core/tests/Drupal/Tests/Core/Cache/BackendChainImplementationUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Cache/BackendChainImplementationUnitTest.php
@@ -7,8 +7,8 @@
 
 namespace Drupal\Tests\Core\Cache;
 
-use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\Core\Cache\BackendChain;
+use Drupal\Core\Cache\Cache;
 use Drupal\Core\Cache\MemoryBackend;
 use Drupal\Tests\UnitTestCase;
 
@@ -222,7 +222,7 @@ public function testNotEmptyIfOneBackendHasTheKey() {
    */
   public function testDeleteAllPropagation() {
     // Set both expiring and permanent keys.
-    $this->chain->set('test1', 1, CacheBackendInterface::CACHE_PERMANENT);
+    $this->chain->set('test1', 1, Cache::PERMANENT);
     $this->chain->set('test2', 3, time() + 1000);
     $this->chain->deleteAll();
 
@@ -237,8 +237,8 @@ public function testDeleteAllPropagation() {
    */
   public function testDeleteTagsPropagation() {
     // Create two cache entries with the same tag and tag value.
-    $this->chain->set('test_cid_clear1', 'foo', CacheBackendInterface::CACHE_PERMANENT, array('test_tag' => 2));
-    $this->chain->set('test_cid_clear2', 'foo', CacheBackendInterface::CACHE_PERMANENT, array('test_tag' => 2));
+    $this->chain->set('test_cid_clear1', 'foo', Cache::PERMANENT, array('test_tag' => 2));
+    $this->chain->set('test_cid_clear2', 'foo', Cache::PERMANENT, array('test_tag' => 2));
     $this->assertNotSame(FALSE, $this->firstBackend->get('test_cid_clear1')
       && $this->firstBackend->get('test_cid_clear2')
       && $this->secondBackend->get('test_cid_clear1')
@@ -258,8 +258,8 @@ public function testDeleteTagsPropagation() {
       'Two caches removed from all backends after clearing a cache tag.');
 
     // Create two cache entries with the same tag and an array tag value.
-    $this->chain->set('test_cid_clear1', 'foo', CacheBackendInterface::CACHE_PERMANENT, array('test_tag' => array(1)));
-    $this->chain->set('test_cid_clear2', 'foo', CacheBackendInterface::CACHE_PERMANENT, array('test_tag' => array(1)));
+    $this->chain->set('test_cid_clear1', 'foo', Cache::PERMANENT, array('test_tag' => array(1)));
+    $this->chain->set('test_cid_clear2', 'foo', Cache::PERMANENT, array('test_tag' => array(1)));
     $this->assertNotSame(FALSE, $this->firstBackend->get('test_cid_clear1')
       && $this->firstBackend->get('test_cid_clear2')
       && $this->secondBackend->get('test_cid_clear1')
@@ -279,9 +279,9 @@ public function testDeleteTagsPropagation() {
       'Two caches removed from all backends after clearing a cache tag.');
 
     // Create three cache entries with a mix of tags and tag values.
-    $this->chain->set('test_cid_clear1', 'foo', CacheBackendInterface::CACHE_PERMANENT, array('test_tag' => array(1)));
-    $this->chain->set('test_cid_clear2', 'foo', CacheBackendInterface::CACHE_PERMANENT, array('test_tag' => array(2)));
-    $this->chain->set('test_cid_clear3', 'foo', CacheBackendInterface::CACHE_PERMANENT, array('test_tag_foo' => array(3)));
+    $this->chain->set('test_cid_clear1', 'foo', Cache::PERMANENT, array('test_tag' => array(1)));
+    $this->chain->set('test_cid_clear2', 'foo', Cache::PERMANENT, array('test_tag' => array(2)));
+    $this->chain->set('test_cid_clear3', 'foo', Cache::PERMANENT, array('test_tag_foo' => array(3)));
     $this->assertNotSame(FALSE, $this->firstBackend->get('test_cid_clear1')
       && $this->firstBackend->get('test_cid_clear2')
       && $this->firstBackend->get('test_cid_clear3')
diff --git a/core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php b/core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php
index 7885679d9905..58e740dc7b54 100644
--- a/core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php
+++ b/core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php
@@ -7,8 +7,8 @@
 
 namespace Drupal\Tests\Core\Cache;
 
+use Drupal\Core\Cache\Cache;
 use Drupal\Tests\UnitTestCase;
-use Drupal\Core\Cache\CacheBackendInterface;
 
 /**
  * Tests the cache CacheCollector.
@@ -200,7 +200,7 @@ public function testUpdateCache() {
       ->with($this->cid, FALSE);
     $this->cache->expects($this->once())
       ->method('set')
-      ->with($this->cid, array($key => $value), CacheBackendInterface::CACHE_PERMANENT, array());
+      ->with($this->cid, array($key => $value), Cache::PERMANENT, array());
     $this->lock->expects($this->once())
       ->method('release')
       ->with($this->cid . ':Drupal\Core\Cache\CacheCollector');
@@ -306,7 +306,7 @@ public function testUpdateCacheMerge() {
       ->will($this->returnValue($cache));
     $this->cache->expects($this->once())
       ->method('set')
-      ->with($this->cid, array('other key' => 'other value', $key => $value), CacheBackendInterface::CACHE_PERMANENT, array());
+      ->with($this->cid, array('other key' => 'other value', $key => $value), Cache::PERMANENT, array());
     $this->lock->expects($this->once())
       ->method('release')
       ->with($this->cid . ':Drupal\Core\Cache\CacheCollector');
@@ -347,7 +347,7 @@ public function testUpdateCacheDelete() {
       ->with($this->cid, TRUE);
     $this->cache->expects($this->once())
       ->method('set')
-      ->with($this->cid, array(), CacheBackendInterface::CACHE_PERMANENT, array());
+      ->with($this->cid, array(), Cache::PERMANENT, array());
     $this->lock->expects($this->once())
       ->method('release')
       ->with($this->cid . ':Drupal\Core\Cache\CacheCollector');
diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php
index 6fc7c1ceea1b..2d0315b94702 100644
--- a/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php
@@ -7,7 +7,7 @@
 
 namespace Drupal\Tests\Core\Menu;
 
-use Drupal\Core\Cache\CacheBackendInterface;
+use Drupal\Core\Cache\Cache;
 use Drupal\Core\Language\Language;
 use Drupal\Tests\UnitTestCase;
 use Symfony\Component\HttpFoundation\Request;
@@ -178,13 +178,13 @@ public function testGetLocalTaskForRouteWithEmptyCache() {
 
     $this->cacheBackend->expects($this->at(2))
       ->method('set')
-      ->with('local_task:en', $definitions, CacheBackendInterface::CACHE_PERMANENT);
+      ->with('local_task:en', $definitions, Cache::PERMANENT);
 
     $expected_set = $this->getLocalTasksCache();
 
     $this->cacheBackend->expects($this->at(3))
       ->method('set')
-      ->with('local_task:en:menu_local_task_test_tasks_view', $expected_set, CacheBackendInterface::CACHE_PERMANENT, array('local_task' => 1));
+      ->with('local_task:en:menu_local_task_test_tasks_view', $expected_set, Cache::PERMANENT, array('local_task' => 1));
 
     $local_tasks = $this->manager->getLocalTasksForRoute('menu_local_task_test_tasks_view');
     $this->assertEquals($result, $local_tasks);
-- 
GitLab