Skip to content

Commit

Permalink
Backport cache fix to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshulse authored Feb 19, 2024
1 parent 324970e commit 38b9759
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Support/Caching/CachedDataConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,21 @@ public function __construct()

public function getDataClass(string $class): DataClass
{
return $this->cache?->getDataClass($class) ?? parent::getDataClass($class);
if (array_key_exists($class, $this->dataClasses)) {
return $this->dataClasses[$class];
}

if ($this->cache === null) {
return parent::getDataClass($class);
}

$dataClass = $this->cache->getDataClass($class);

if ($dataClass === null) {
return parent::getDataClass($class);
}

return $this->dataClasses[$class] = $dataClass;
}

public function setCache(DataStructureCache $cache): self
Expand Down

0 comments on commit 38b9759

Please sign in to comment.