Default values are only applied to null keys, not non-existing keys
Cache::put('keyThatIsNull', null, 1);
dd(Cache::many([
'keyThatIsNull' => 'You will see this string',
'keyThatDoesNotExist' => 'But this default value does not work, you\'ll get false instead',
]));
output:
array:2 [
"keyThatIsNull" => "You will see this string"
"keyThatDoesNotExist" => false
]
Where did you get this? many() accepts an array of keys with no default values.
since it wasn't in the docs for cache, I had to look through the source. Check out line 124:
https://github.com/illuminate/cache/blob/master/Repository.php
I see now, but I can't replicate your issue:
\Cache::put('keyThatIsNull', null, 1);
dd(\Cache::many([
'keyThatIsNull' => 'You will see this string',
'keyThatDoesNotExist' => 'But this default value does not work, you\'ll get false instead',
]));
The results is:
array:2 [â–¼
"keyThatIsNull" => "You will see this string"
"keyThatDoesNotExist" => "But this default value does not work, you'll get false instead"
]
Are you using phpredis?
Ok I've opened a PR with a fix: https://github.com/laravel/framework/pull/18984
Thanks :)
Thanks!
Most helpful comment
Ok I've opened a PR with a fix: https://github.com/laravel/framework/pull/18984
Thanks :)