Skip to content

Commit

Permalink
[5.x] Cache structure on nav tree instance (#9648)
Browse files Browse the repository at this point in the history
Co-authored-by: Jason Varga <jason@pixelfear.com>
  • Loading branch information
JohnathonKoster and jasonvarga authored Mar 12, 2024
1 parent 8d6bec3 commit a919983
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Structures/NavTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@

class NavTree extends Tree implements TreeContract
{
private $structureCache;

public function structure()
{
return Blink::once('nav-tree-structure-'.$this->handle(), function () {
if ($this->structureCache) {
return $this->structureCache;
}

return $this->structureCache = Blink::once('nav-tree-structure-'.$this->handle(), function () {
return Nav::findByHandle($this->handle());
});
}
Expand Down

0 comments on commit a919983

Please sign in to comment.