Issue #2169447 by damiankloip, sun, longwave: DX: Supply CacheBackendInterface::CACHE_PERMANENT as Cache::PERMANENT.

8.0.x
webchick 2014-01-25 21:21:53 -08:00
parent 394442e270
commit b8ef75c5f4
34 changed files with 104 additions and 101 deletions

View File

@ -15,7 +15,6 @@ use Symfony\Component\HttpFoundation\Request;
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())));

View File

@ -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));
}
}

View File

@ -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;
}

View File

@ -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));
}
}
}

View File

@ -123,7 +123,7 @@ class BackendChain implements CacheBackendInterface {
/**
* 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);
}

View File

@ -12,6 +12,11 @@ namespace Drupal\Core\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.
*

View File

@ -146,7 +146,7 @@ interface CacheBackendInterface {
* @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.

View File

@ -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 @@ abstract class CacheCollector implements CacheCollectorInterface, DestructableIn
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);
}

View File

@ -118,7 +118,7 @@ class DatabaseBackend implements CacheBackendInterface {
}
// 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 @@ class DatabaseBackend implements CacheBackendInterface {
/**
* 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 @@ class DatabaseBackend implements CacheBackendInterface {
public function garbageCollection() {
try {
Database::getConnection()->delete($this->bin)
->condition('expire', CacheBackendInterface::CACHE_PERMANENT, '<>')
->condition('expire', Cache::PERMANENT, '<>')
->condition('expire', REQUEST_TIME, '<')
->execute();
}

View File

@ -83,7 +83,7 @@ class MemoryBackend implements CacheBackendInterface {
}
// 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 @@ class MemoryBackend implements CacheBackendInterface {
/**
* 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,

View File

@ -36,7 +36,7 @@ class MemoryCounterBackend extends MemoryBackend {
/**
* 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);
}

View File

@ -45,7 +45,7 @@ class NullBackend implements CacheBackendInterface {
/**
* 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().

View File

@ -77,7 +77,7 @@ class CachedStorage implements StorageInterface, StorageCacheInterface {
// 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 @@ class CachedStorage implements StorageInterface, StorageCacheInterface {
$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 @@ class CachedStorage implements StorageInterface, StorageCacheInterface {
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 @@ class CachedStorage implements StorageInterface, StorageCacheInterface {
$this->cache->set(
'find:' . $prefix,
$this->findByPrefixCache[$prefix],
CacheBackendInterface::CACHE_PERMANENT,
Cache::PERMANENT,
array($this::FIND_BY_PREFIX_CACHE_TAG => TRUE)
);
}

View File

@ -145,7 +145,8 @@ class EntityManager extends PluginManagerBase implements EntityManagerInterface
$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 @@ class EntityManager extends PluginManagerBase implements EntityManagerInterface
}
}
$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 @@ class EntityManager extends PluginManagerBase implements EntityManagerInterface
}
}
$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));
}
}

View File

@ -9,6 +9,7 @@ namespace Drupal\Core\Menu;
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 @@ class LocalTaskManager extends DefaultPluginManager {
'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) {

View File

@ -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 @@ class DefaultPluginManager extends PluginManagerBase implements PluginManagerInt
*/
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;
}

View File

@ -10,7 +10,6 @@ namespace Drupal\Core\Plugin\Discovery;
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;

View File

@ -239,7 +239,7 @@ class Registry implements DestructableInterface {
* 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 @@ class Registry implements DestructableInterface {
}
// 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));
}
}

View File

@ -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 @@ abstract class CacheArray implements \ArrayAccess {
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);
}

View File

@ -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 @@ class ThemeRegistry extends CacheCollector implements DestructableInterface {
$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);
}

View File

@ -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 @@ class BookManager {
}
// 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 @@ class BookManager {
$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;
}

View File

@ -209,7 +209,7 @@ class FieldInfo {
// 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 @@ class FieldInfo {
}
// 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 @@ class FieldInfo {
}
// 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 @@ class FieldInfo {
// 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 @@ class FieldInfo {
// 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];
}

View File

@ -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;

View File

@ -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,
));

View File

@ -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 @@ class RelationLinkManager implements RelationLinkManagerInterface{
}
// 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));
}
}

View File

@ -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 @@ class TypeLinkManager implements TypeLinkManagerInterface {
}
// 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));
}
}

View File

@ -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 @@ abstract class GenericCacheBackendUnitTestBase extends DrupalUnitTestBase {
$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 @@ abstract class GenericCacheBackendUnitTestBase extends DrupalUnitTestBase {
// 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 @@ abstract class GenericCacheBackendUnitTestBase extends DrupalUnitTestBase {
$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 @@ abstract class GenericCacheBackendUnitTestBase extends DrupalUnitTestBase {
$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 @@ abstract class GenericCacheBackendUnitTestBase extends DrupalUnitTestBase {
$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 @@ abstract class GenericCacheBackendUnitTestBase extends DrupalUnitTestBase {
$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 @@ abstract class GenericCacheBackendUnitTestBase extends DrupalUnitTestBase {
$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 @@ abstract class GenericCacheBackendUnitTestBase extends DrupalUnitTestBase {
$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 @@ abstract class GenericCacheBackendUnitTestBase extends DrupalUnitTestBase {
$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 @@ abstract class GenericCacheBackendUnitTestBase extends DrupalUnitTestBase {
$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 @@ abstract class GenericCacheBackendUnitTestBase extends DrupalUnitTestBase {
$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 @@ abstract class GenericCacheBackendUnitTestBase extends DrupalUnitTestBase {
$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();

View File

@ -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;
}

View File

@ -9,6 +9,7 @@ namespace Drupal\user;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\PrivateKey;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface;
/**
@ -57,7 +58,7 @@ class PermissionsHash implements PermissionsHashInterface {
}
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;

View File

@ -9,7 +9,6 @@ namespace Drupal\views\Plugin\views\cache;
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 @@ abstract class CachePluginBase extends PluginBase {
* The cache type, either 'query', 'result' or 'output'.
*/
protected function cacheSetExpire($type) {
return CacheBackendInterface::CACHE_PERMANENT;
return Cache::PERMANENT;
}
/**

View File

@ -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 @@ class Time extends CachePluginBase {
return time() + $lifespan;
}
else {
return CacheBackendInterface::CACHE_PERMANENT;
return Cache::PERMANENT;
}
}

View File

@ -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 @@ class BackendChainImplementationUnitTest extends UnitTestCase {
*/
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 @@ class BackendChainImplementationUnitTest extends UnitTestCase {
*/
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 @@ class BackendChainImplementationUnitTest extends UnitTestCase {
'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 @@ class BackendChainImplementationUnitTest extends UnitTestCase {
'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')

View File

@ -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 @@ class CacheCollectorTest extends UnitTestCase {
->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 @@ class CacheCollectorTest extends UnitTestCase {
->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 @@ class CacheCollectorTest extends UnitTestCase {
->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');

View File

@ -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 @@ class LocalTaskManagerTest extends UnitTestCase {
$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);