Skip to content

Commit efa909e

Browse files
committed
will not cache null values anymore
1 parent ca72203 commit efa909e

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/Services/Cache/FileCache.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ public function remember(
5858

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

61-
// store
62-
Filesystem::put($path, serialize($value));
61+
// store only if not null
62+
if ($value !== null) {
63+
Filesystem::put($path, serialize($value));
64+
}
6365

6466
return $value;
6567
}
@@ -93,9 +95,12 @@ public function set($key, $value, $ttl = null): bool
9395
$path = $this->keyPath((string) $key, true);
9496
$value = $this->value($value);
9597

96-
// store
97-
Filesystem::put($path, serialize($value));
98-
return true;
98+
// store only if not null
99+
if ($value !== null) {
100+
Filesystem::put($path, serialize($value));
101+
return true;
102+
}
103+
return false;
99104

100105
// ttl is not used on file cache
101106
// other providers may

0 commit comments

Comments
 (0)