Cache can be tricky, I would only look at data that doesn't change or rarely changes. I would see if Jeffrey has an advanced video or lesson on this, it is an advanced subject indeed.
How to cache records with Eloquent?
I am trying to understand how to use cache to cache data when using eloquent to reduce the amount of connections/queries to the database.
It is my understanding, when caching a data set using eloquent you can do the following some
User::Where('status','Active')->with('Teams')->remember(60)->get();
The above code should cache the result for 60 minutes "Please correct me if I am wrong."
Now, the second time I run the same line of code, will Eloquent automatically pull the records from the the cache or do I have to do a manual check to see if the records exists in the cache then I load it from the cache otherwise execute the above code?
Also, if I have 10 users on the same system and all 10 need the same result set will the data be reloaded from the cache for 9 users? Or will each dataset be associated with one user?
Finally, can I cache the dataset from a raw query using DB::raw?
Does Eloquent store the query and the dataset in the cache so it knows how to search for it in the cache the next time around?
Please or to participate in this conversation.