Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 292540

Make cache()->get() return a classed CacheItem object

$
0
0

Problem/Motivation

We return an stdClass from cache->get(), but there's no enforcement of which keys are in it (id? created? expires? tags?), only $cached->data is in everything since code will immediately break without it. To be able to consistently chain cache tag implementations, we'd need to be able to know the tags of a cache item when it's retrieved, something that's not currently required or supported by cache backends.

We can leave $cached->data as a public property at the moment for bc, then remove it in a follow-up since that will touch a lot of code.

Proposed resolution

  • Return CacheItem on every cache backend in core
  • Wrap cache backends to ensure they return CacheItem always
  • Allow cache backends to opt out of this decoration

Remaining tasks

  • Write a change record
  • Write a Unit test for CacheItemCacheBackendDecorator
  • Maybe extend \Drupal\KernelTests\Core\Cache\GenericCacheBackendUnitTestBase?

User interface changes

API changes

Data model changes


Viewing all articles
Browse latest Browse all 292540

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>