By dawehner on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
11.5.x
Introduced in version:
11.5.0
Description:
drupal_static() and drupal_static_reset() have been deprecated .
Before:
drupal_static()
After:
$cid = 'unique_identifier';
$cached = \Drupal::cache('memory')->get($cid);
$data = $cached->data ?? NULL;
...
\Drupal::cache('memory')->set($cid, $data);
Before:
drupal_static_reset()
After:
\Drupal::cache('memory')->delete($cid);
Impacts:
Module developers
Themers
Site templates, recipes and distribution developers
Comments
It looks like the approach
It looks like the approach being taken in Core is often to leverage the site cache to replace drupal_static() implementations. As such, if you want something to help implement custom caching, check out https://www.drupal.org/project/cache_register.
Deprecation has been postponed to D11
See the original issue: https://www.drupal.org/node/2260187