hmones/laravel-cacheable
Composer 安装命令:
composer require hmones/laravel-cacheable
包简介
A simple package to automatically cache the returns of certain methods in a given class and forgets them as well on request.The package is highly configurable and let you manage naming of the cache keys with ease.
README 文档
README
A simple package to automatically cache the returns of certain methods in a given class and forgets them as well on request. The package is highly configurable and let you manage naming of the cache keys with ease.
Installation
Via Composer
composer require hmones/laravel-cacheable
Configuration
To publish the package configuration
php artisan vendor:publish --tag=laravel-cacheable-config
The configuration file contains the following parameters:
ttl: the default time to live for caching functions- Env variable:
CACHEABLE_TTL - Default value:
3600
- Env variable:
param-keys-enabledwhether you would like to add function parameters to keys of the stored cache items. Note: Make sure that the parameters are strings or integers, otherwise adding the parameters wouldn't work.- Env variable:
CACHEABLE_PARAM_KEYS_ENABLED - Default value:
false
- Env variable:
cache-tags-enabledwhether you would like to add tags as the method name to the cached keys, this will allow you to store multiple instances of the calls if you choose to add parameters to it, and then when you want to delete them all you can simply delete everything with this tag. The application takes care of that on it's own if you callforgetCallbased on the settings you choose here.- Env variable:
CACHEABLE_TAGS - Default value:
false
- Env variable:
prefixif you would like to set a default prefix to all cacheable items- Env variable:
CACHEABLE_PREFIX - Default value: ``
- Env variable:
suffixif you would like to set a default suffix to all cacheable items- Env variable:
CACHEABLE_SUFFFIX - Default value: ``
- Env variable:
Usage
- Make sure your class extend
\Hmones\LaravelCacheable\Cacheable - Instead of calling the method in the class directly, call
CLASS::cacheCall('methodName', ['argument1' => 'value', 'argument2' => 'value']) - You can remove the cached method call as follows:
- If you have redis and/or any cache driver that supports tagging, even if you have enabled the parameters' addition to cache keys, you can simply call
CLASS::forgetCall('methodName) - If you don't have a cache driver that supports tags, and you have enabled adding functions parameters to the cache, you must include the arguments in the forget call as follows:
CLASS::forgetCall('methodName', ['argument1' => 'value', 'argument2' => 'value'])
- If you have redis and/or any cache driver that supports tagging, even if you have enabled the parameters' addition to cache keys, you can simply call
Example: Sending a digest email every time 10 new users register on the website with a summary of their names.
Change log
Please see the changelog for more information on what has changed recently.
Testing
composer test
Contributing
Please see contributing.md for details and a todolist.
Security
If you discover any security related issues, please email author email instead of using the issue tracker.
Credits
License
Please see the license file for more information.
hmones/laravel-cacheable 适用场景与选型建议
hmones/laravel-cacheable 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 07 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「LaravelCacheable」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 hmones/laravel-cacheable 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hmones/laravel-cacheable 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 hmones/laravel-cacheable 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Alfabank REST API integration
Laravel package for Accurate Online API integration.
Shared RCX Laravel DataTables UI and configuration helpers.
Boot a Laravel project on any machine with one command: app:serve installs missing tools (PHP, Node, Composer, Herd, Docker), creates .env, sets up the database, runs migrations, builds assets, starts a queue worker and serves via Herd, Sail or artisan serve; app:down cleanly stops everything it sta
Branded, diagnostic error pages (500, 403, 404, 419, 503) for Filament — native Filament UI, dark mode and translations out of the box.
Turn any PDF into a Pingen-ready A4 letter (generated address cover page + A4 normalisation + safe margins) and send it through the Pingen print & mail API. Laravel-first.
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-14