sofascore/purgatory-bundle
Composer 安装命令:
composer require sofascore/purgatory-bundle
包简介
A Symfony bundle for HTTP cache invalidation with support for various backends like Varnish.
README 文档
README
Purgatory is a Symfony bundle for HTTP cache invalidation, designed to automatically generate and send cache purge requests to HTTP cache backends like Symfony's HTTP cache or Varnish. It leverages Doctrine events to track changes in entities and generates URLs that need purging based on configured routes.
Features
-
Doctrine Event Integration: Listens to Doctrine lifecycle events (
postUpdate,postRemove,postPersist) to automatically detect when entities are modified, created, or deleted. -
Automatic URL Generation: Automatically generates purge requests for relevant URLs based on the affected entities and their associated routes.
-
Flexible Configuration:
- Primary configuration is done through the
#[PurgeOn]attribute, allowing you to annotate controller actions with cache purge rules based on entities used in the response. - Supports YAML configuration for flexibility depending on your project's requirements.
- Primary configuration is done through the
-
Built-in Purger Support: Comes with built-in support for Symfony HTTP Cache and a basic Varnish implementation. For advanced use cases, you can create custom purgers by implementing the
PurgerInterface. -
Asynchronous Processing: Includes built-in support for Symfony Messenger to process purge requests asynchronously for better scalability and efficiency.
Requirements
- PHP 8.1 or higher
- Symfony 6.4 or Symfony 7.4 or higher
Installation
Require the bundle using Composer:
composer require sofascore/purgatory-bundle
If your project doesn't use Symfony Flex, continue with the following steps:
-
Create a configuration file under
config/packages/purgatory.yaml. Here's a reference configuration:purgatory: # List of files or directories where Purgatory will look for additional purge definitions. mapping_paths: [] # Route names that match the given regular expressions will be ignored. route_ignore_patterns: [] # Examples: # - /^_profiler/ # - /^_wdt/ doctrine_middleware: enabled: true # Explicitly set the priority of Purgatory's Doctrine middleware. priority: null # Explicitly set the priorities of Purgatory's Doctrine event listener. doctrine_event_listener_priorities: preRemove: null postPersist: null postUpdate: null # This event is not registered when the Doctrine middleware is enabled. postFlush: null purger: # The ID of a service that implements the "Sofascore\PurgatoryBundle\Purger\PurgerInterface" interface name: null # Example: symfony # The hosts from which URLs should be purged hosts: [] # The service ID of the HTTP client to use, must be an instance of Symfony's HTTP client http_client: null messenger: # Set the name of the messenger transport to use transport: null # Set the name of the messenger bus to use bus: null # Set the number of urls to dispatch per message batch_size: null # Enables the data collector and profiler panel if the profiler is enabled. profiler_integration: true
-
Enable the bundle in
config/bundles.phpby adding it to the array:Sofascore\PurgatoryBundle\PurgatoryBundle::class => ['all' => true],
Usage
For detailed instructions and examples, refer to the documentation.
Versioning
This project follows Semantic Versioning 2.0.0.
Reporting Issues
Use the issue tracker to report any issues you encounter.
License
See the LICENSE file for details (MIT).
sofascore/purgatory-bundle 适用场景与选型建议
sofascore/purgatory-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 73.73k 次下载、GitHub Stars 达 118, 最近一次更新时间为 2023 年 02 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「http」 「cache」 「caching」 「varnish」 「invalidation」 「purge」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sofascore/purgatory-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sofascore/purgatory-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sofascore/purgatory-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Query caching for Laravel 5
Laravel 5 - Repositories to the database layer
Simple PHP caching system that uses a tmp folder in a Linux environment.
Provides support for PSR-6 compatible cache for Yii1 application
http客户端
统计信息
- 总下载量: 73.73k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 118
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-02-23