anorgan / laravel-cache by anorgan

Laravel Cache package that supports tagging
16
3
1
Package Data
Maintainer Username: anorgan
Maintainer Contact: marin.crnkovic@gmail.com (Marin Crnković)
Package Create Date: 2017-03-19
Package Last Update: 2017-10-11
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2025-05-01 03:06:00
Package Statistics
Total Downloads: 16
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 3
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

Cache models by tagging

Latest Version Quality Score Build Status GitHub license

This package aims to help with caching of models by tagging them and invalidating caches on model change.

Installation

Install this package via composer by running:

composer require anorgan/laravel-cache:^1.0

Add to providers:

// config/app.php
'providers' => [
    ...
    Anorgan\LaravelCache\LaravelCacheServiceProvider::class
];

To publish the config, run:

php artisan vendor:publish --provider="Anorgan\LaravelCache\LaravelCacheServiceProvider" --tag="config"

Config looks like this:

<?php

return [
    /*
     * Add keys per model which should be invalidated alongside default model key and tags,
     * e.g. for Product::class, you would like to invalidate cache with key "product_listing"
     */
    'invalidate' => [
        \App\Product::class => [
            'product_listing'
        ]
    ],
];

Testing

You can run the tests with:

$ vendor/bin/phpunit

Contributing

Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see License File for more information.