Laravel’s ORM cache package

LaraCache is an ORM based Laravel package for creating, updating and managing cache items based on model queries. Using this package, you can cache queries that are heavily used throughout your application.

 use Mostafaznv\LaraCache\Traits\LaraCache;   class Article extends Model {     use LaraCache;       public static function cacheEntities(): array     {         return [             CacheEntity::make('list.forever')                 ->cache(function() {                     return Article::query()->latest()->get();                 }),               CacheEntity::make('latest')                 ->validForRestOfDay()                 ->cache(function() {                     return Article::query()->latest()->first();                 })         ];     } }

Use this

The post Laravel’s ORM cache package first appeared on Lenix Blog .

This article is reprinted from https://blog.p2hp.com/archives/8821
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment