D
D
devmailer2018-09-15 15:19:23
Laravel
devmailer, 2018-09-15 15:19:23

How to solve the problem with caching while the worker is running?

There are two tables Users and Settings, they are connected via hasMany,
those settings can be obtained by $user->settings
And there is some abstract Job task in which the user settings are necessary for the work,
let's say the user in the settings set that he wants to receive notifications notify = true (in the database this is see if you look) and if you get somewhere just in the code, then I also get true, but when the Job takes the settings, it sees false there and if you reload the worker, it already comes true, after each change of any setting, you need to restart the workers, which is nonsense
, I run the workers through the supervisor php artisan queue:work --daemon I
write settings $user->settings->update(['notify' => true]);
I get $user->settings->notify;
or
$settings = Settings::where('user_id' => $userId)->get();
$settings->notify;
Prompt in. what could be the question?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Shumov, 2018-09-15
@inoise

1. We separate the concepts of pool generation into a notification and a notification sender.
2. Suppose an event X has occurred. The event "X has occurred, here is the data (for example)" falls into the system.
3. Events from paragraph 2 fall into very (Rabbit MQ, Kafka). They are listened to by the notification generator.
4. The notification generator receives a pool of users for this particular event (it can cache it for a short period, for example, memcached) and creates tasks in the "notify user A about event X" queue
5. The notifier simply performs the tasks from paragraph 4
No reason

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question