cvsouth / cache-null
允许 Laravel 缓存 null 值的支持
1.0.5
2022-02-01 16:53 UTC
Requires
- illuminate/support: 5.5.*|5.6.*|5.7.*|5.8.*|6.0.*|^7.0|^8.0|^9.0
README
在 Laravel 中默认情况下,根据 PSR-16 规范,缓存的 null 值与缓存未命中是不同的
A cache miss will return null and therefore detecting if one stored null is not possible.
Cache::forever('test1a', null); $exists = Cache::has('test1a'); // returns FALSE $value = Cache::rememberForever('test1b', function() { print('calculating'); return null; }); // 'calculating' prints every single time
如果您想启用对缓存 null 值的支持,请安装此包
Cache::forever('test2a', null); $exists = Cache::has('test2a'); // returns TRUE $value = Cache::rememberForever('test2b', function() { print('calculating'); return null; }); // 'calculating' prints only the first time
安装
composer require cvsouth/cache-null
注意
此包目前只支持 redis 缓存驱动程序。