Last updated January 10, 2013. Created by mitchell on January 10, 2013.
Log in to edit this page.
A previous, temporary implementation that implemented prefix/wildcard cache clears in Drupal 8 (deletePrefix()) has since been removed in favor of the new tag invalidation functionality.
Comparison:
<?php
// Drupal 7
cache_set("theme_registry:$theme->name", $registry);
cache_clear_all('theme_registry', 'cache', TRUE);
// Drupal 8
cache()->set("theme_registry:$theme->name", $registry, CacheBackendInterface::CACHE_PERMANENT, array('theme_registry' => TRUE));
cache()->deleteTags(array('theme_registry' => TRUE));
?>Furthermore, we renamed _cache_get_object() to simply cache(). You should now use the factory directly, instead of the old procedural wrappers, which have been removed.
For example:
<?php
if ($cached = cache()->get($cid)) {
return $cached->data;
}
else {
$data = rebuild_my_data();
cache()->set($cid, $data);
}
// Or with a $bin other than 'cache'.
$cache = cache('bootstrap');
$cache->get($cid);
$cache->set($cid, $data);
$cids = array(1, 2, 3);
$cache->getMultiple($cids);
$cache->deleteAll();
}
?>