Same name and namespace in other branches
  1. 10 core/lib/Drupal.php \Drupal::cache()
  2. 9 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

39 calls to Drupal::cache()
BlockTest::testBlockCacheTags in core/modules/block/tests/src/Functional/BlockTest.php
Test that cache tags are properly set and bubbled up to the page cache.
BreadcrumbFrontCacheContextsTest::setUp in core/modules/system/tests/src/Functional/Menu/BreadcrumbFrontCacheContextsTest.php
CachePluginBase::cacheGet in core/modules/views/src/Plugin/views/cache/CachePluginBase.php
Retrieve data from the cache.
CachePluginBase::cacheSet in core/modules/views/src/Plugin/views/cache/CachePluginBase.php
Save data to the cache.
CacheTestBase::assertCacheRemoved in core/modules/system/tests/src/Functional/Cache/CacheTestBase.php
Asserts that a cache entry has been removed.

... See full list

File

core/lib/Drupal.php, line 316
Contains \Drupal.

Class

Drupal
Static Service Container wrapper.

Code

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