定制 tv2regionerne/statamic-cache 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

tv2regionerne/statamic-cache

Composer 安装命令:

composer require tv2regionerne/statamic-cache

包简介

README 文档

README

Statamic Autocache is an addon that automatically caches the content of any partials for a faster response time and selective invalidation

How to Install

Run the following command from your project root:

composer require tv2regionerne/statamic-cache

Then run the migrations:

php artisan migrate

You can also optionally publish the config:

php artisan vendor:publish --tag=statamic-cache-config

How to Use

The addon should work automatically in most cases. It adds hooks to partial, nav and collection tags, as well as augmentation of entries and globals to determine what content is included in what partials. This data is then added to a database store that is used to determine what cached data should be invalidated at what times.

The default cache is used, or you can specify a cache store called statamic_autocache if you want to have more control over when it is cleared.

Middleware

The autocache middleware will automatically be added to your web middleware stack. If you want to include it to other stacks simply add:

\Tv2regionerne\StatamicCache\Http\Middleware\Autocache::class

Store

The addon comes with a Facade for interacting with the Store: \Tv2regionerne\StatamicCache\Facades\Store

If you want to add extra data to the store you can do so using in your AppServiceProvider, eg:

MyTag::hook('init', function () {
	Store::mergeTags(['my_tag:id']);
});

Make sure you also invalidate the tag in a listener:

Store::invalidateContent(['my_tag:id']);

Custom cache driver with database index

Run the migrations to add the static_cache table.

This add-on will automatically add a redis_with_database cache driver to your Statamic install. To use it change the half measure static cache driver in config/statamic/static_caching.php to use redis_with_database, and ensure statamic.static_caching.strategy is set to half.

'half' => [
    'driver' => 'redis_with_database',
    'expiry' => null,
],

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 4
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2024-01-11