DEV Community

Morcos Gad
Morcos Gad

Posted on • Updated on

Laravel Caching - PlanetScale MySQL

I found this great resource that shows us the importance of Caching and its use in enhancing the performance of our project.

  • What is caching

A common pain point in applications is optimizing and reducing the number of trips you have to take to the database. Say you have an e-commerce admin dashboard. Maybe you have a page that displays all inventory — every product, associated category, vendors, and more. A single page like this may perform dozens of calls to your database before the page can even display any data. If you don't think about how to handle this, your application can quickly become slow and costly.

One option to reduce the number of times you have to go to the database is through caching. Caching allows you to store specific data in application memory so that next time that query is hit, you already have the data on hand and won't have to go back to the database for it. Keep in mind, this is different from browser caching, which is user-based. This article covers application caching, which happens at the application level and cannot be cleared by the user.

Laravel has robust built-in functionality https://laravel.com/docs/9.x/cache that makes caching a breeze.

Let's see it in action!

Visit the source and learn about Planet Scale MySQL and use caching :-
https://planetscale.com/blog/introduction-to-laravel-caching

I hope you enjoyed the code as much as I enjoyed sharing it with you.

Top comments (0)