Skip to content

Commit

Permalink
will not cache null values anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
andrefelipe committed Dec 22, 2022
1 parent ca72203 commit efa909e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Services/Cache/FileCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ public function remember(

$value = $this->value($value);

// store
Filesystem::put($path, serialize($value));
// store only if not null
if ($value !== null) {
Filesystem::put($path, serialize($value));
}

return $value;
}
Expand Down Expand Up @@ -93,9 +95,12 @@ public function set($key, $value, $ttl = null): bool
$path = $this->keyPath((string) $key, true);
$value = $this->value($value);

// store
Filesystem::put($path, serialize($value));
return true;
// store only if not null
if ($value !== null) {
Filesystem::put($path, serialize($value));
return true;
}
return false;

// ttl is not used on file cache
// other providers may
Expand Down

0 comments on commit efa909e

Please sign in to comment.