Skip to content

Commit

Permalink
[4.x] Only retrieve from origin blink cache when its not null (#9661)
Browse files Browse the repository at this point in the history
Co-authored-by: Jason Varga <jason@pixelfear.com>
  • Loading branch information
ryanmitchell and jasonvarga committed Mar 4, 2024
1 parent 28f3f2f commit 563abc0
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Data/HasOrigin.php
Expand Up @@ -60,9 +60,17 @@ public function origin($origin = null)
{
return $this->fluentlyGetOrSet('origin')
->getter(function ($origin) {
return $origin
? Blink::once($this->getOriginBlinkKey(), fn () => $this->getOriginByString($origin))
: null;
if (! $origin) {
return null;
}

if ($found = Blink::get($this->getOriginBlinkKey())) {
return $found;
}

return tap($this->getOriginByString($origin), function ($found) {
Blink::put($this->getOriginBlinkKey(), $found);
});
})
->setter(function ($origin) {
Blink::forget($this->getOriginBlinkKey());
Expand Down

0 comments on commit 563abc0

Please sign in to comment.