function cache

Instantiates and statically caches the correct class for a cache bin.

By default, this returns an instance of the Drupal\Core\Cache\DatabaseBackend class.

Classes implementing Drupal\Core\Cache\CacheBackendInterface can register themselves both as a default implementation and for specific bins.

Parameters

$bin: The cache bin for which the cache object should be returned, defaults to 'cache'.

Return value

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

See also

Drupal\Core\Cache\CacheBackendInterface

3 calls to cache()
CacheDecoratorTest::testCachedDefinitions in drupal/core/modules/system/lib/Drupal/system/Tests/Plugin/CacheDecoratorTest.php
Tests that discovered definitions are properly cached.
CacheDecoratorTest::testClearCachedDefinitions in drupal/core/modules/system/lib/Drupal/system/Tests/Plugin/CacheDecoratorTest.php
Tests CacheDecorator::clearCachedDefinitions().
TwigEnvironment::__construct in drupal/core/lib/Drupal/Core/Template/TwigEnvironment.php
Constructs a TwigEnvironment object and stores cache and storage internally.
41 string references to 'cache'
AliasTest::testCRUD in drupal/core/modules/system/lib/Drupal/system/Tests/Path/AliasTest.php
AliasTest::testLookupPath in drupal/core/modules/system/lib/Drupal/system/Tests/Path/AliasTest.php
AliasTest::testWhitelist in drupal/core/modules/system/lib/Drupal/system/Tests/Path/AliasTest.php
Tests the alias whitelist.
BlockCacheTest::setCacheMode in drupal/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php
Private helper method to set the test block's cache mode.
BlockTest::testBlockRehash in drupal/core/modules/block/lib/Drupal/block/Tests/BlockTest.php
Test _block_rehash().

... See full list

File

drupal/core/includes/cache.inc, line 28
Functions and interfaces for cache handling.

Code

function cache($bin = 'cache') {
  return Drupal::cache($bin);
}