mevada-kalpesh/cache-watcher 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mevada-kalpesh/cache-watcher

Composer 安装命令:

composer require mevada-kalpesh/cache-watcher

包简介

Cache Watcher is a powerful Laravel package designed to turbocharge your application's performance by optimizing data management through caching

README 文档

README

Cache Watcher is a powerful Laravel package designed to turbocharge your application's performance by optimizing data management through caching. With Cache Watcher, you can seamlessly manage your data while enjoying automatic updates when changes occur.

Result

Alt Text

Installation

You can install the package via composer if this command give error add :dev-main at last as a version:

composer require mevada-kalpesh/cache-watcher

Add This Provider in Providers in config/app.php after installing the package

 Kalpesh\CacheWatcher\CacheWatchServiceProvider::class

You can publish the config file with:

php artisan vendor:publish --provider="Kalpesh\CacheWatcher\CacheWatchServiceProvider"

This is the contents of the published config file:

// config/cache-watcher.php

<?php

return [
    /*
    *   Time will be consider into minutes
    */
    'expire_time' => 1440,


    /*
    *   Cache Store Name  
    */
    'store' => env('CACHE_DRIVER', 'file'),
];

Usage

for use this just you can follow this

use Kalpesh\CacheWatcher\Facade\CacheWatch;
  // When any values change, the cache is automatically invalidated, and the latest data is fetched using the query.
  $search = "Johsn";
  $pagination = 10;
  $sortBy = "DESC"    

  $posts =  CacheWatch::setQuery(function () use ($search,$pagination,$sortBy){
    // You can use any complex query with Cache Watcher.
      return Post::where('name','like',"%$search%") 
            ->orderby('id',$sortBy)
            ->paginate($pagination);
  })
  //You can set your model as a watcher using `watchModals(YOUR MODALS ARRAY)` function, which means if any changes occur with this model, the cache will be automatically removed and updated with the new data.
  ->watchModals(['Post'])  
  ->done();

Make sure you add the namespace correctly as shown above.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

License

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

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-04