Skip to content

Latest commit

 

History

History
41 lines (29 loc) · 1.26 KB

File metadata and controls

41 lines (29 loc) · 1.26 KB
title Cache
description Configuring a custom cache driver

Cache

By default, Laravel Zero uses the array driver for caching. This means that using the Cache facade will work out of the box for the remainder of a commands process.

You can configure one or more custom cache drivers for your application by creating a new config/cache.php file.

For example, if you wanted to use the file driver, you could add the following:

<?php

return [
    'default' => 'file',

    'stores' => [
        'file' => [
            'driver' => 'file',
            'path' => storage_path('framework/cache/data'),
        ],
    ],
];

Note, this will not work in a compiled app as the storage path in the Phar cannot be accessed. See the Filesystem docs for more details.

Once implemented, you can then use the Cache facade as with a standard Laravel application.

use Illuminate\Support\Facades\Cache;

Cache::put('full_name', 'Johnny Lawrence');
Cache::get('full_name');

Full details on using the Cache drivers are available on the main Laravel documentation.