hmones/laravel-cacheable 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

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

Build Status Style CI Total Downloads Latest Stable Version License

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
  • param-keys-enabled whether 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
  • cache-tags-enabled whether 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 call forgetCall based on the settings you choose here.
    • Env variable: CACHEABLE_TAGS
    • Default value: false
  • prefix if you would like to set a default prefix to all cacheable items
    • Env variable: CACHEABLE_PREFIX
    • Default value: ``
  • suffix if you would like to set a default suffix to all cacheable items
    • Env variable: CACHEABLE_SUFFFIX
    • Default value: ``

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'])

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 我们能提供哪些服务?
定制开发 / 二次开发

基于 hmones/laravel-cacheable 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-07-14