Lumen File Cache Driver

I am in Lumen, inside the controller, and I would like to cache the result of the calculation in a simple and simple way, without using databases or external services, so I was looking to save the cache in the file system. In the Laravel documentation , the file driver is specified:

By default, Laravel is configured to use a file cache driver that stores serialized, cached objects on the file system.

And I see it, configured as the default cache store, inside config/cache.php .

In the Lumen Documentation, I don't see anything about the file driver, and I don't see anything like the cache.php file inside the Lumen installation.

So my question is, can I use the file cache driver in Lumen (by setting CACHE_DRIVER=file ) or if it is discouraged, not supported, not implemented, or something else?

+5
source share
1 answer

In Lumen in .env.example you default:

 CACHE_DRIVER=memcached 

So all you need is to change the file name from .env.example to .env and set

 CACHE_DRIVER=file 

If you read Caching in Lumen , you will see in the example:

 $value = Cache::store('file')->get('foo'); 

therefore the file driver is supported by Lumen.

If you also read Lumen Configuration , you can read here that you can copy the necessary configuration files (if necessary) and download them manually. You can see the Luman default cache configuration file: https://github.com/laravel/lumen-framework/blob/5.1/config/cache.php

+8
source

Source: https://habr.com/ru/post/1239508/


All Articles