mohit-yogi/async-db-helper
Composer 安装命令:
composer require mohit-yogi/async-db-helper
包简介
Save the model data to redis & then move them to DB later
README 文档
README
Async DB Helper
Introduction
Sometimes it happens that we use either logger or some special models to log the user data, which is critical to collect but not so much that waste our precious DB connection & resource on it. Like Auditing records for a model.
To help in such scenario, you can use this package. This package stores the records which were meant for DB into redis & moves them to DB on scheduled basis.
How to use
use the trait AsyncDBHelpingTrait in the models where you want them to be in async mode. It will override the create & save methods for the model.
- In case of save, if model doesn't exists than only it will be put in async mode.
- There are two methods available which you can define in you model, where you are using the AsyncDBHelpingTrait, beforeMoveToRedis & afterMoveToRedis
- beforeMoveToRedis : As the name suggest, this function runs before moving the data from redis to DB. While running this function, model will be holding the same data as saved into redis.
- afterMoveToRedis : this function runs after moving the data from redis to DB. The model at this point will hold all the data as saved into redis and primary key value (id).
Move data from redis to DB:
- You can run the command move-to-db:redis periodically to move the data from redis to DB.
- The command receives an optional argument batch_size, default set to 1000. The batch size is the number of records which will be moved from redis to DB in one go.
mohit-yogi/async-db-helper 适用场景与选型建议
mohit-yogi/async-db-helper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 03 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 mohit-yogi/async-db-helper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mohit-yogi/async-db-helper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-03-26