function Drupal::cache

Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal.php \Drupal::cache()
  2. 10 core/lib/Drupal.php \Drupal::cache()
  3. 11.x core/lib/Drupal.php \Drupal::cache()

Returns the requested cache bin.

Parameters

string $bin: (optional) The cache bin for which the cache object should be returned, defaults to 'default'.

Return value

\Drupal\Core\Cache\CacheBackendInterface The cache object associated with the specified bin.

Related topics

14 calls to Drupal::cache()
DatabaseBackendTagTest::testTagInvalidations in core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTagTest.php
DrupalTest::testCache in core/tests/Drupal/Tests/Core/DrupalTest.php
Tests the cache() method.
EntityLastInstalledSchemaRepository::__construct in core/lib/Drupal/Core/Entity/EntityLastInstalledSchemaRepository.php
Constructs a new EntityLastInstalledSchemaRepository.
EntityViewBuilderTest::testEntityViewBuilderCache in core/tests/Drupal/KernelTests/Core/Entity/EntityViewBuilderTest.php
Tests entity render cache handling.
RegistryLegacyTest::testMultipleSubThemes in core/tests/Drupal/KernelTests/Core/Theme/RegistryLegacyTest.php
Tests the theme registry with theme functions and multiple subthemes.

... See full list

File

core/lib/Drupal.php, line 348

Class

Drupal
Static Service Container wrapper.

Code

public static function cache($bin = 'default') {
  return static::getContainer()->get('cache.' . $bin);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.