laravel / octane

Supercharge your Laravel application's performance.
https://laravel.com/docs/octane
MIT License
3.78k stars 296 forks source link

No default store in cache.php for "octane" #145

Closed mrbenosborne closed 3 years ago

mrbenosborne commented 3 years ago

Description:

There is no default cache store setup for "octane", when trying to access the store the below exception is thrown.

InvalidArgumentException
Cache store [octane] is not defined.

Steps To Reproduce:

Create a new laravel project

composer create-project laravel/laravel octane-test

Require Octane

composer require laravel/octane

Run octane:install

php artisan octane:install

Set config to use Swoole

<?php

use Laravel\Octane\Contracts\OperationTerminated;
use Laravel\Octane\Events\RequestHandled;
use Laravel\Octane\Events\RequestReceived;
use Laravel\Octane\Events\RequestTerminated;
use Laravel\Octane\Events\TaskReceived;
use Laravel\Octane\Events\TickReceived;
use Laravel\Octane\Events\WorkerErrorOccurred;
use Laravel\Octane\Events\WorkerStarting;
use Laravel\Octane\Events\WorkerStopping;
use Laravel\Octane\Listeners\CollectGarbage;
use Laravel\Octane\Listeners\DisconnectFromDatabases;
use Laravel\Octane\Listeners\EnsureUploadedFilesAreValid;
use Laravel\Octane\Listeners\FlushTemporaryContainerInstances;
use Laravel\Octane\Listeners\ReportException;
use Laravel\Octane\Listeners\StopWorkerIfNecessary;
use Laravel\Octane\Octane;

return [

    /*
    |--------------------------------------------------------------------------
    | Octane Server
    |--------------------------------------------------------------------------
    |
    | This value determines the default "server" that will be used by Octane
    | when starting, restarting, or stopping your server via the CLI. You
    | are free to change this to the supported server of your choosing.
    |
    | Supported: "roadrunner", "swoole"
    |
    */

    'server' => env('OCTANE_SERVER', 'swoole'),

Attempt to use the store "octane" as per the README.md

<?php

use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Cache;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    Cache::store('octane')->put('framework', 'Laravel', 30);
});
mrbenosborne commented 3 years ago

I solved it by putting the following in my cache.php file.

  'octane' => [
      'driver' => 'octane',
  ]