I just started with Lumen and i transfer a pure PHP written Skript into Lumen. The Skript should return its result very, very fast so I tried to transfer every task that can be done later to the queue.
One of this tasks is saving the data to a remote Database.
My questions:
When I initiate a new Eloquent Model, will it try to connect to the DB even before I do save()? (I talk about the models that have the remote db connection)
Can I somehow put the DB save process to the queue? When I give the Object to the Queue to save it (without an save() before), it will only serialize the id and will not be able to fetch it from the worker (because the model is not saved yet).
The only solution I see right now is to prepare the data for the model and create the eloquent model in the worker (which is not that nice).
How I solved it for now:
I only have some parameters in the Model, so I create an array in the right format for the model::create function, give it to the job and the handler runs Model::create().
I think sending array to the job its the best choise.. if you want speed why to initiad eloquent model with data and than send it to the job? let the job do the hard job