{"id":"72e03989811e1505","repo":"laravel/framework","slug":"cache-driver-not-available-scheduling-unique-jobs","errorCode":null,"errorMessage":"Cache driver not available. Scheduling unique jobs not supported.","messagePattern":"Cache driver not available\\. Scheduling unique jobs not supported\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Console/Scheduling/Schedule.php","lineNumber":280,"sourceCode":"        $this->getDispatcher()->dispatch(\n            $job->onConnection($connection)->onQueue($queue)\n        );\n    }\n\n    /**\n     * Dispatch the given unique job to the queue.\n     *\n     * @param  object  $job\n     * @param  string|null  $queue\n     * @param  string|null  $connection\n     * @return void\n     *\n     * @throws \\RuntimeException\n     */\n    protected function dispatchUniqueJobToQueue($job, $queue, $connection)\n    {\n        if (! Container::getInstance()->bound(Cache::class)) {\n            throw new RuntimeException('Cache driver not available. Scheduling unique jobs not supported.');\n        }\n\n        if (! (new UniqueLock(Container::getInstance()->make(Cache::class)))->acquire($job)) {\n            return;\n        }\n\n        $this->getDispatcher()->dispatch(\n            $job->onConnection($connection)->onQueue($queue)\n        );\n    }\n\n    /**\n     * Dispatch the given job right now.\n     *\n     * @param  object  $job\n     * @return void\n     */\n    protected function dispatchNow($job)","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Console/Scheduling/Schedule.php#L262-L298","documentation":"Thrown by Schedule::dispatchUniqueJobToQueue() (src/Illuminate/Console/Scheduling/Schedule.php:280) when a scheduled job implementing ShouldBeUnique is dispatched but no Cache\\Repository is bound in the container. Unique locking relies on the cache to acquire a UniqueLock.","triggerScenarios":"Schedule::job(MyUniqueJob::class) where MyUniqueJob implements ShouldBeUnique, in an app where the cache is not bound (config/cache.php missing, or running outside Laravel with only illuminate/bus/console and no cache binding).","commonSituations":"Custom cache driver misconfiguration (CACHE_DRIVER=array/null), disabled cache in test/bootstrap, or a standalone Laravel subset without illuminate/cache bound.","solutions":["Ensure config/cache.php exists and CACHE_DRIVER/STORE is set to a valid store (redis, database, file).","Bind a cache repository in the container: $container->instance(\\Illuminate\\Contracts\\Cache\\Repository::class, $cacheRepo).","Remove ShouldBeUnique from the job if uniqueness is not required.","Run php artisan config:cache after fixing cache config."],"exampleFix":"// before\n// .env -> CACHE_STORE=null\n$schedule->job(SyncUniqueJob::class)->hourly();  // SyncUniqueJob implements ShouldBeUnique\n\n// after\n// .env -> CACHE_STORE=redis\n$schedule->job(SyncUniqueJob::class)->hourly();","handlingStrategy":"validation","validationCode":"if (! \\Illuminate\\Container\\Container::getInstance()->bound(\\Illuminate\\Contracts\\Cache\\Repository::class)) {\n    // bind a cache store or drop ShouldBeUnique\n}","typeGuard":"function cacheBound(): bool\n{\n    return \\Illuminate\\Container\\Container::getInstance()->bound(\\Illuminate\\Contracts\\Cache\\Repository::class);\n}","tryCatchPattern":"try {\n    $schedule->job(UniqueJob::class)->hourly();\n} catch (\\RuntimeException $e) {\n    // fall back to non-unique dispatch or fail loudly\n}","preventionTips":["Configure a real CACHE_STORE (redis/database/file) for unique jobs.","Bind \\Illuminate\\Contracts\\Cache\\Repository explicitly in non-Laravel boots.","Don't mark jobs ShouldBeUnique unless a cache is reliably available."],"tags":["scheduling","queue","cache","unique-job","laravel"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}