mongdch/mon-cache
Composer 安装命令:
composer require mongdch/mon-cache
包简介
The PSR-16 simple cache utils.
README 文档
README
一个基于PSR-16实现的缓存库,内置File、Redis缓存驱动,支持自定义扩展缓存驱动
使用
$config = [ // 默认缓存驱动 'default' => 'file', // 缓存驱动 'stores' => [ // 文件缓存 'file' => [ // 驱动器 'driver' => File::class, // 默认缓存有效时间 'expire' => 0, // 使用子目录保存 'cache_subdir' => false, // 缓存前缀 'prefix' => '', // 缓存路径 'path' => __DIR__ . '/cache', // 数据压缩 'data_compress' => false, ], // Redis缓存 'redis' => [ // 驱动器 'driver' => Redis::class, // 链接host 'host' => '127.0.0.1', // 链接端口 'port' => 6379, // 链接密码 'auth' => '', // 读取超时时间 'timeout' => 2, // 自定义键前缀 'prefix' => '', // 默认缓存有效时间 'expire' => 0, // redis数据库 'database' => 1, // 保持链接 'persistent' => false, ] ] ]; // 获取缓存实例 $cache = new Cache($config); // 设置 $set = $cache->set('ab', 'ab'); $set = $cache->set('abc', 'abc', 10); // 批量设置 $mSet = $cache->setMultiple(['a' => 1, 'b' => '2', 'c' => 3]); // 获取 $data = $cache->get('ab', 'd'); // 批量获取 $mGet = $cache->getMultiple(['a', 'b', 'c', 'd'], ['c' => 'aaa']); // $mGet = $cache->getMultiple(['a', 'b', 'c', 'd'], 'default'); // 是否存在 $has = $cache->has('ab'); // 删除 $del = $cache->delete('b'); // 批量删除 $mDel = $cache->deleteMultiple(['a', 'd']); // 获取并删除 $pull = $cache->pull('ab', 'def'); // 清空缓存 $clear = $cache->clear();
Gaia框架支持
composer安装后执行php gaia vendor:publish mon\cache即可
mongdch/mon-cache 适用场景与选型建议
mongdch/mon-cache 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 138 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 09 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cache」 「psr-16」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mongdch/mon-cache 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mongdch/mon-cache 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mongdch/mon-cache 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Simple PSR-16 cache implementations for WordPress transient the OOP way
Laravel 5 - Repositories to the database layer
Always-offline PSR-16 cache implemention, for fallback and testing
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.
Laravel 5 - Repositories to the database layer
统计信息
- 总下载量: 138
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 7
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-09-09