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 @@
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())));
......
......@@ -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));
}
}
......
......@@ -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;
}
......
......@@ -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));
}
}
}
......
......@@ -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);
}
......
......@@ -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.
*
......
......@@ -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.
......
......@@ -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);
}
......
......@@ -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();
}
......
......@@ -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,
......
......@@ -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);
}
......
......@@ -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().
......
......@@ -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)
);
}
......
......@@ -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));
}
}
......
......@@ -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) {
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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));
}
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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;
}
......
......@@ -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];
}
......
......@@ -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;
......
......@@ -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,
));
......
......@@ -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));
}
}
......@@ -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));
}
}
......@@ -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);