Charrua's avatar

Are Event Listeners cached in some way?

Hello, I'm using a simple event listener to detect when a notification is sent using a particular channel. In my case is NotificationChannels\Twilio\TwilioChannel.

Sometimes when I update this file, and upload to server, it seems that the update is not working... So I'm thinking if this is some cache in play... Any ideas?

Do you flush cache when updating Event Listeners?

Thank you.

0 likes
8 replies
Braunson's avatar

From the docs..

... during your deployment process, you should run the event:cache Artisan command to cache a manifest of all of your application's events and listeners

So yes event & listeners are cached. Clear your cache on deployment and if you are using queue's, restart them on deploy.

Charrua's avatar

@braunson @click

As I understand from the docs:

Event Discovery is available for Laravel 5.8.9 or later.

And under Event Discovery is what you quote:

... during your deployment process, you should run the event:cache Artisan command to cache a manifest of all of your application's events and listeners

But I think this is only for Event Discovery (automatic event discovery) and not for manually registered events (as I use)

BTW I'm using v5.7

click's avatar
click
Best Answer
Level 35

Do you have a queue running? If so, you need to restart the queue worker when you "change the file" otherwise your queue is working with the old file.

How do you change the file on the server? Because your server could have something like Opcache which caches the php files itself. Try restarting php-fpm after a deployment.

3 likes
Charrua's avatar

Yes I have a queue running, I'll restart the queue and come back here. I upload files using a git repository. Thank you

Snapey's avatar

event discovery is cached. NOT the events themselves.

Charrua's avatar

Great, that's what I understand form docs. Thank you for sharing your thoughts.

Charrua's avatar

Seems that restarting the queue and the worker fixed the issue. Thank you for your help!

Please or to participate in this conversation.