流明文件缓存驱动程序
Lumen file cache driver
我在 Lumen 的控制器内,我想以一种简单易行的方式缓存计算结果,而不使用数据库或外部服务,所以我一直在寻找将缓存保存在文件系统中的方法。在 Laravel's documentation 中引用了 file
驱动程序:
By default, Laravel is configured to use the file cache driver, which
stores the serialized, cached objects in the filesystem.
我可以看到它,在 config/cache.php
.
中配置为 默认缓存存储
在 Lumen's documentation 中,我看不到任何关于文件驱动程序的信息,而且我在 Lumen 安装中找不到任何类似文件 cache.php
的东西。
所以我的问题是我是否可以在 Lumen 中使用文件缓存驱动程序(通过设置 CACHE_DRIVER=file
),或者是否不鼓励、不支持、未实现或其他原因?
在 .env.example
中的 Lumen 默认情况下:
CACHE_DRIVER=memcached
所以你只需要将文件名从 .env.example
更改为 .env
并设置
CACHE_DRIVER=file
如果您阅读 Caching in Lumen,您会在示例中看到:
$value = Cache::store('file')->get('foo');
因此 file
Lumen 支持驱动程序。
如果你也阅读了Lumen Configuration you can read here that you can copy configuration files you need (in case you need them) and load them manually. You can see default Luman cache config file here: https://github.com/laravel/lumen-framework/blob/5.1/config/cache.php
我在 Lumen 的控制器内,我想以一种简单易行的方式缓存计算结果,而不使用数据库或外部服务,所以我一直在寻找将缓存保存在文件系统中的方法。在 Laravel's documentation 中引用了 file
驱动程序:
By default, Laravel is configured to use the file cache driver, which stores the serialized, cached objects in the filesystem.
我可以看到它,在 config/cache.php
.
在 Lumen's documentation 中,我看不到任何关于文件驱动程序的信息,而且我在 Lumen 安装中找不到任何类似文件 cache.php
的东西。
所以我的问题是我是否可以在 Lumen 中使用文件缓存驱动程序(通过设置 CACHE_DRIVER=file
),或者是否不鼓励、不支持、未实现或其他原因?
在 .env.example
中的 Lumen 默认情况下:
CACHE_DRIVER=memcached
所以你只需要将文件名从 .env.example
更改为 .env
并设置
CACHE_DRIVER=file
如果您阅读 Caching in Lumen,您会在示例中看到:
$value = Cache::store('file')->get('foo');
因此 file
Lumen 支持驱动程序。
如果你也阅读了Lumen Configuration you can read here that you can copy configuration files you need (in case you need them) and load them manually. You can see default Luman cache config file here: https://github.com/laravel/lumen-framework/blob/5.1/config/cache.php