Laravel Model Caching Package: Model-caching made easy

Laravel Model Caching Package: Model-caching made easy

The Laravel Model caching is a package by Mike Bronner that adds Model caching to model queries automatically. Here are the main highlight features from the package’s readme:

  • Automatic, self-invalidating relationship (both eager- and lazy-loaded) caching.
  • Automatic, self-invalidating model query caching.
  • Automatic use of cache tags for cache providers that support them (will flush entire cache for providers that don’t).

The readme also outlines the inspiration and reason Mike created the package in the first place:

I created this package in response to a client project that had complex, nested forms with many <select>’s that resulted in over 700 database queries on one page. I needed a package that abstracted the caching process out of the model for me, and one that would let me cache custom queries, as well as cache model relationships. This package is the attempt to address those requirements.

For the best performance, you should use a “taggable” cache provider like Redis or Memcached. With all model queries and relationships cached, you will see a nice performance boost. Your mileage will vary on performance based on your use-case.

For more information check out the GitHub repository.

Filed in: Laravel Packages
Laravel News Partners

Laravel Jobs

Senior Full-Stack Developer
Atlanta, GA - (remote) USA ONLY
Curricula
PHP Laravel Developer
London
Investoo
Looking for Senior Full-stack Laravel/React.js Javascript API Developer - Immediate (Full-time)
Remote
ApproveMe // Document Signing
Wordpress and/or Laravel Developer
Remote (Lexington, KY)
Mediocre Creative
Software Developer
Huntsville, AL
Spur

Newsletter

Join 31,000+ others and never miss out on new tips, tutorials, and more.