All Projects → AuthentikCanada → eloquent-cache

AuthentikCanada / eloquent-cache

Licence: GPL-3.0 License
Easily cache your Laravel's Eloquent models.

Programming Languages

PHP
23972 projects - #3 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to eloquent-cache

Laravel Repositories
[ABANDONED] Rinvex Repository is a simple, intuitive, and smart implementation of Active Repository with extremely flexible & granular caching system for Laravel, used to abstract the data layer, making applications more flexible to maintain.
Stars: ✭ 664 (+1107.27%)
Mutual labels:  eloquent, cache
Lada Cache
A Redis based, fully automated and scalable database cache layer for Laravel
Stars: ✭ 424 (+670.91%)
Mutual labels:  eloquent, cache
Simple Cache
An easy to use Caching trait for Laravel's Eloquent Models.
Stars: ✭ 19 (-65.45%)
Mutual labels:  eloquent, cache
Laravel Eloquent Query Cache
Adding cache on your Laravel Eloquent queries' results is now a breeze.
Stars: ✭ 529 (+861.82%)
Mutual labels:  eloquent, cache
Laravel Cacheable
Rinvex Cacheable is a granular, intuitive, and fluent caching system for eloquent models. Simple, but yet powerful, plug-n-play with no hassle.
Stars: ✭ 107 (+94.55%)
Mutual labels:  eloquent, cache
resilience4clj-circuitbreaker
Resilience4Clj circuit breaker lets you decorate a function call (usually with a potential of external failure) with a safety mechanism to interrupt the propagation of failures.
Stars: ✭ 40 (-27.27%)
Mutual labels:  cache
GraphCMS-cache-boilerplate
The main goal of this service is to provide a reliable cache contingency backup plan in case a GraphCMS/GraphQL endpoint is failing.
Stars: ✭ 24 (-56.36%)
Mutual labels:  cache
AspSqliteCache
An ASP.NET Core IDistributedCache provider backed by SQLite
Stars: ✭ 39 (-29.09%)
Mutual labels:  cache
proxpi
PyPI caching mirror
Stars: ✭ 19 (-65.45%)
Mutual labels:  cache
transitory
In-memory cache with high hit rates via LFU eviction for Node and browsers. Supports time-based expiration, automatic loading and metrics.
Stars: ✭ 24 (-56.36%)
Mutual labels:  cache
component-box
A little component cacher 📦
Stars: ✭ 25 (-54.55%)
Mutual labels:  cache
eloquent-traits
Traits for laravel eloquent models
Stars: ✭ 18 (-67.27%)
Mutual labels:  eloquent
type-cacheable
TypeScript-based caching decorator (currently supports Redis, LRU-Cache and NodeCache)
Stars: ✭ 96 (+74.55%)
Mutual labels:  cache
papercut
Papercut is a scraping/crawling library for Node.js built on top of JSDOM. It provides basic selector features together with features like Page Caching and Geosearch.
Stars: ✭ 15 (-72.73%)
Mutual labels:  cache
HAProxy-2-RPM-builder
Build latest HAProxy binary with prometheus metrics support
Stars: ✭ 28 (-49.09%)
Mutual labels:  cache
elara
Elara DB is an easy to use, lightweight key-value database that can also be used as a fast in-memory cache. Manipulate data structures in-memory, encrypt database files and export data. 🎯
Stars: ✭ 93 (+69.09%)
Mutual labels:  cache
lsdis
KV storage based on LocalStorage.
Stars: ✭ 17 (-69.09%)
Mutual labels:  cache
Ccache.cmake
🚅 Compile faster with Ccache! A Ccache integration for CMake with Xcode support.
Stars: ✭ 24 (-56.36%)
Mutual labels:  cache
salad
Asynchronous Scala Redis Client supporting Sentinel and Redis Cluster
Stars: ✭ 14 (-74.55%)
Mutual labels:  cache
pacman.store
Pacman Mirror via IPFS for ArchLinux, Endeavouros and Manjaro
Stars: ✭ 65 (+18.18%)
Mutual labels:  cache

Eloquent Cache

Easily cache your Laravel's Eloquent models.

Build Status Coverage Status Latest Stable Version Total Downloads

Requirements

  • PHP >= 7.2

  • Laravel 6 / 7 / 8

Installation

Install via composer :

composer require authentik/eloquent-cache

How it works

  • When Eloquent fetches models, the JSON representations of the model instances are cached.

  • Subsequently, when eloquent fetches a model by ID, the cached JSON will be converted back into an instance.

Usage

Use the Cacheable trait in the models you want to cache.

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Authentik\EloquentCache\Cacheable;

class Category extends Model
{
    use Cacheable;


    /*
     * You can optionally override the following functions:
     */
    
    // Time To Live in minutes (default value: 0 => no TTL)
    public function getCacheTTL() {
        return 60;
    }

    // default value: the lowercase name of the model
    public function getCacheTagName() {
        return 'cat';
    }

    // Cache busting will automatically invalidate the cache when model instances are updated or deleted.
    // default value: true
    public function isCacheBustingEnabled() {
        return false;
    }

    // Whether or not to keep model instances in a static array cache
    //  (useful to avoid querying the cache store/building instances from json multiple times)
    // default value: true
    public function isStaticCacheEnabled() {
        return false;
    }
}

To manually cache a model instance, use the cache method.

Category::find(1)->cache();

To invalidate the cache for a model instance, use the refresh or flush method.

$refreshedInstance = Category::find(1)->refresh();

// or

Category::flush(Category::find(1));

To invalidate the cache for all instances of a model, use the flush method.

Category::flush();

Changelog

Click Here

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].