I have a question to improve my code and the performance of my laravel apps. I was wondering if there is any query cache or something like that when querying the same ressource multiple times.
Let's say I have the following validation rule:
'group' => 'exists:groups,id|required',
The validator will query the group with id X. After the validation I need the group entity to modify it or build a json respone with it. So I have to query it again within the controller.
I'm doing this all the time and I don't like it. Is this the common way? Or is there a better method to do this?
Laravel doesn't offer this out of the box at the moment.
You can build in your own caching for queries, however you can't use that cache in the current exists validation rule. What you can do is setup your own validation rule that uses this caching part. This way you can reuse the same query (or it's cache) during the same request.