tv2regionerne / statamic-cache
此包最新版本(dev-main)没有提供许可证信息。
dev-main
2024-09-04 10:15 UTC
Requires
- php: ^8.2
- pixelfear/composer-dist-plugin: ^0.1.5
- statamic/cms: ^4.0 || ^5.0
Requires (Dev)
- laravel/pint: ^1.13
- mockery/mockery: ^1.3.1
- nunomaduro/collision: ^6.0 || ^7.0
- orchestra/testbench: ^7.0 || ^8.0
- pestphp/pest: ^2.24
- phpunit/phpunit: ^9.0 || ^10.0
- dev-main
- dev-feature/lock-when-flushing
- dev-feature/cache-headers
- dev-split-brain-check-configurable
- dev-syda-update
- dev-fix/some-issues-with-cache-clearing
- dev-invalidate-when-no-db-entry
- dev-fix/actually-invalidate-the-cache
- dev-fix/chunk-when-we-have-a-config-limit
- dev-fix/autocache-urls
- dev-feature/test-suite-merge-models
- dev-feature/unique-job-on-queue
- dev-feature/nuke-cache-if-we-dont-have-a-tracker
- dev-feature/custom_cache_driver
- dev-feature/chunked
- dev-feature/queued
- dev-fix/use-hooks-properly
- dev-fix/switch-to-simpler-cache-approach
- dev-feature/move-to-middleware
- dev-feature/add-expiry-and-tags
- dev-feature/syda
- dev-feature/refactor-to-use-hooks
This package is auto-updated.
Last update: 2024-09-04 10:15:40 UTC
README
Statamic Autocache 是一个插件,可以自动缓存任何部分的页面内容,以提高响应速度和选择性失效
如何安装
从您的项目根目录运行以下命令
composer require tv2regionerne/statamic-cache
然后运行迁移
php artisan migrate
您还可以选择发布配置
php artisan vendor:publish --tag=statamic-cache-config
如何使用
大多数情况下,插件会自动工作。它为部分、导航和集合标签添加钩子,以及增强条目和全局变量以确定哪些内容包含在哪些部分中。然后,这些数据被添加到数据库存储中,用于确定何时使缓存数据失效。
使用默认缓存,或者如果您想更控制何时清除,可以指定名为 statamic_autocache
的缓存存储。
中间件
autocache 中间件将自动添加到您的 web
中间件堆栈。如果您想将其添加到其他堆栈,只需添加
\Tv2regionerne\StatamicCache\Http\Middleware\Autocache::class
存储
该插件提供了一个用于与存储交互的门面:\Tv2regionerne\StatamicCache\Facades\Store
如果您想在存储中添加额外的数据,可以在 AppServiceProvider 中这样做,例如
MyTag::hook('init', function () { Store::mergeTags(['my_tag:id']); });
确保在监听器中使标签失效
Store::invalidateContent(['my_tag:id']);
带有数据库索引的自定义缓存驱动程序
运行迁移以添加静态_cache 表。
此插件会自动将 redis_with_database
缓存驱动程序添加到您的 Statamic 安装中。要使用它,请将 config/statamic/static_caching.php
中的半措施静态缓存驱动程序更改为使用 redis_with_database
,并确保 statamic.static_caching.strategy
设置为 half
。
'half' => [ 'driver' => 'redis_with_database', 'expiry' => null, ],