morilog/infinity-cache

Laravel Eloquent 模型和查询的无限缓存

v1.0.1 2016-02-14 06:41 UTC

This package is auto-updated.

Last update: 2024-09-21 04:07:45 UTC


README

这是一个为 Laravel Eloquent 缓存的 Laravel 扩展包。InfinityCache 提供无限和永久的缓存,直到模型发生变化为止。如果一个模型已经被创建、删除或更新,模型查询缓存将被清空。

要求

此包仅与 可标记的缓存存储 和如 memcachedRedis 以及扩展自 Illuminate\Cache\TaggedCache 的其他存储驱动程序兼容。

安装

要安装此包,请运行以下 composer 命令

composer require morilog/infinity-cache

将 ServiceProvider 添加到您的 config/app.php 提供者数组中

    'providers' => [
        ...
        Morilog\InfinityCache\InfinityCacheServiceProvider::class,
        ...
    ]

然后发布配置文件

php artisan vendor:publish --provider="Morilog\InfinityCache\InfinityCacheServiceProvider" --tag="config"

用法

要使用 InfinityCache,您的 Eloquent 模型必须扩展 Morilog\InfinityCache\Model

示例

<?php
namespace App\Models;

use Morilog\InfinityCache\Model as InfinityCacheModel;

class Post extends InfinityCacheModel
{
  ...
}