2006-06-14 14:01:12 +00:00
|
|
|
<?php
|
|
|
|
|
2009-06-16 23:48:09 +00:00
|
|
|
/**
|
2011-12-05 12:52:27 +00:00
|
|
|
* @file
|
|
|
|
* Functions and interfaces for cache handling.
|
|
|
|
*/
|
|
|
|
|
2013-03-22 09:36:55 +00:00
|
|
|
use Drupal\Core\Cache\Cache;
|
2012-09-04 13:51:51 +00:00
|
|
|
|
2011-12-05 12:52:27 +00:00
|
|
|
/**
|
|
|
|
* Instantiates and statically caches the correct class for a cache bin.
|
2009-06-16 23:48:09 +00:00
|
|
|
*
|
2012-02-01 03:22:12 +00:00
|
|
|
* By default, this returns an instance of the Drupal\Core\Cache\DatabaseBackend
|
2012-01-13 03:19:33 +00:00
|
|
|
* class.
|
|
|
|
*
|
2012-02-01 03:22:12 +00:00
|
|
|
* Classes implementing Drupal\Core\Cache\CacheBackendInterface can register
|
|
|
|
* themselves both as a default implementation and for specific bins.
|
2009-06-16 23:48:09 +00:00
|
|
|
*
|
|
|
|
* @param $bin
|
2011-09-07 18:38:31 +00:00
|
|
|
* The cache bin for which the cache object should be returned, defaults to
|
|
|
|
* 'cache'.
|
2011-12-05 12:52:27 +00:00
|
|
|
*
|
2013-10-03 11:26:25 +00:00
|
|
|
* @return \Drupal\Core\Cache\CacheBackendInterface
|
2009-12-04 16:31:04 +00:00
|
|
|
* The cache object associated with the specified bin.
|
2011-12-05 12:52:27 +00:00
|
|
|
*
|
2013-10-03 11:26:25 +00:00
|
|
|
* @see \Drupal\Core\Cache\CacheBackendInterface
|
2009-06-16 23:48:09 +00:00
|
|
|
*/
|
2011-09-07 18:38:31 +00:00
|
|
|
function cache($bin = 'cache') {
|
2013-09-16 03:58:06 +00:00
|
|
|
return \Drupal::cache($bin);
|
2012-11-28 21:36:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Marks cache items from all bins with any of the specified tags as invalid.
|
2012-04-13 01:49:34 +00:00
|
|
|
*
|
|
|
|
* Many sites have more than one active cache backend, and each backend my use
|
|
|
|
* a different strategy for storing tags against cache items, and invalidating
|
|
|
|
* cache items associated with a given tag.
|
|
|
|
*
|
|
|
|
* When invalidating a given list of tags, we iterate over each cache backend,
|
2012-11-28 21:36:29 +00:00
|
|
|
* and call invalidateTags() on each.
|
2012-04-13 01:49:34 +00:00
|
|
|
*
|
|
|
|
* @param array $tags
|
|
|
|
* The list of tags to invalidate cache items for.
|
2013-03-22 09:36:55 +00:00
|
|
|
*
|
|
|
|
* @deprecated 8.x
|
|
|
|
* Use \Drupal\Core\Cache\Cache::invalidateTags().
|
2012-04-13 01:49:34 +00:00
|
|
|
*/
|
2012-11-28 21:36:29 +00:00
|
|
|
function cache_invalidate_tags(array $tags) {
|
2013-03-22 09:36:55 +00:00
|
|
|
Cache::invalidateTags($tags);
|
2012-04-13 01:49:34 +00:00
|
|
|
}
|