Use with Laravel Octane and Horizon #79
-
How does this function behave when run with Laravel Octane and Horizon? The readme states that the cache only lasts for the duration of a request. Is this the same with Laravel octane? Also does the cache get reset for every new job processed within Horizon? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
This function does not have any Laravel specific awareness or functionality. Under the hood is uses a You can flush the cache manually using
|
Beta Was this translation helpful? Give feedback.
-
For anyone else looking into this -- I haven't implemented Octane yet with Spatie Once, but I believe we should be able to add a // config/octane.php
OperationTerminated::class => [
FlushTemporaryContainerInstances::class,
// DisconnectFromDatabases::class,
// CollectGarbage::class,
FlushSpatieOnce::class, // <-- Here
], // app/Listeners/FlushSpatieOnce.php
use Spatie\Once\Cache;
class FlushSpatieOnce
{
/**
* Handle the event.
*
* @param mixed $event
* @return void
*/
public function handle($event): void
{
Cache::getInstance()->flush();
}
} The |
Beta Was this translation helpful? Give feedback.
-
@stevebauman whenever I find a comment from you on an open source package, it helps to solve a problem, thank you for that. @freekmurze as far as I have tested this solution ( |
Beta Was this translation helpful? Give feedback.
For anyone else looking into this -- I haven't implemented Octane yet with Spatie Once, but I believe we should be able to add a
OperationTerminated
listener to Laravel Octane's config to flush Spatie Once's cache:https://github.com/laravel/octane/blob/bcd6ffe87bd389890fd7ef8ac24b46c579c8b434/config/octane.php#L103-L107