arifhp86/laravel-clear-expired-cache-file
Composer 安装命令:
composer require arifhp86/laravel-clear-expired-cache-file
包简介
Remove laravel expired cache file/folder
README 文档
README
When you use the file cache driver, you may have noticed that the cache files are never deleted automatically. They are overwritten when the cache is refreshed which is good, but if there is some randomness in you cache keys, or for some other reason some of your cache files are never touched again, they will stay on your server forever. This package helps you to get rid of these lingering files.
This package only adds one artisan command: php artisan cache:clear-expired and it will delete all cache files that has already been expired.
Installation
You can install the package via composer:
composer require arifhp86/laravel-clear-expired-cache-file
Usage
Run the following command
php artisan cache:clear-expired
Run on schedule
You can also schedule the command to run automatically. For example, if you want to run the command every day at 1 AM, you can add the following to your app/Console/Kernel.php file:
protected function schedule(Schedule $schedule) { $schedule->command('cache:clear-expired')->dailyAt('01:00'); }
Dry run
You can run the command in dry run mode. In this mode, the command will not delete any files. It will only show you the files that will be deleted if you run the command without the --dry-run option.
php artisan cache:clear-expired --dry-run
Disable directory deletion
By default, the command will delete all empty directories after deleting the expired files. You can disable this behavior by using the --disable-directory-delete option.
php artisan cache:clear-expired --disable-directory-delete
Events
The command triggers three events:
Arifhp86\ClearExpiredCacheFile\Events\GarbageCollectionStarting: Before the command runs.Arifhp86\ClearExpiredCacheFile\Events\GarbageCollectionEnded: After the command runs.Arifhp86\ClearExpiredCacheFile\Events\GarbageCollectionFailed: If the command fails.
You can use these events to run your own code before or after the command runs.
Send email notification after the command runs
// app/Providers/EventServiceProvider.php boot method use Arifhp86\ClearExpiredCacheFile\Events\GarbageCollectionEnded; Event::listen(function (GarbageCollectionEnded $event) { $timeTaken = $event->time; // in seconds $memory = $event->memory; // in bytes $numberOfFilesDeleted = $event->expiredFiles->getCount(); $diskCleared = $event->expiredFiles->getFormattedSize(); $remainingFiles = $event->activeFiles->getCount(); $remainingDisk = $event->activeFiles->getFormattedSize(); $numberOfDeletedDirectories = $event->deletedDirectories; // Send email notification //... });
Send email notification if the command fails
// app/Providers/EventServiceProvider.php boot method use Arifhp86\ClearExpiredCacheFile\Events\GarbageCollectionFailed; Event::listen(function (GarbageCollectionFailed $event) { $exception = $event->exception; $message = $exception->getMessage(); $stackTrace = $exception->getTraceAsString(); // Send email notification //... });
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
arifhp86/laravel-clear-expired-cache-file 适用场景与选型建议
arifhp86/laravel-clear-expired-cache-file 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 140.02k 次下载、GitHub Stars 达 34, 最近一次更新时间为 2019 年 05 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cache」 「laravel」 「clear」 「expired」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 arifhp86/laravel-clear-expired-cache-file 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 arifhp86/laravel-clear-expired-cache-file 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 arifhp86/laravel-clear-expired-cache-file 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Laravel 5 - Repositories to the database layer
Adds a command to easily clear all your defined queues at once.
WordPress Plugin extends Timber WP plugin with clearing cache functionality.
Rinvex Repository is a simple, intuitive, and smart implementation of Active Repository with extremely flexible & granular caching system for Laravel, used to abstract the data layer, making applications more flexible to maintain.
This yii extension helps you to clear remembered filter values on GridViews, by using the additional top right image.
统计信息
- 总下载量: 140.02k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 36
- 点击次数: 30
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-05-02