ebethus/mongodb-laravel-cache
Composer 安装命令:
composer require ebethus/mongodb-laravel-cache
包简介
A mongodb cache driver for laravel
README 文档
README
A MongoDB cache driver for Laravel
| Laravel Version |
Package Version |
Install using this command |
|---|---|---|
| 5.7.x | 2.11.x | composer require 1ff/laravel-mongodb-cache:~2.11.0 |
| 5.8.x, 6.x | 2.12.x | composer require 1ff/laravel-mongodb-cache:~2.12.0 |
| 7.x | 3.x.x | composer require 1ff/laravel-mongodb-cache:^3.1 |
| 8.x | 4.x.x | composer require 1ff/laravel-mongodb-cache:^4.1 |
| 9.x | 5.x.x | composer require 1ff/laravel-mongodb-cache:^5.0 |
Installation
Install using composer:
composer require 1ff/laravel-mongodb-cache
If you are using Laravel older than 5.5 add the service provider in config/app.php:
'ForFit\Mongodb\Cache\ServiceProvider::class',
Add the mongodb cache store in config/cache.php
'stores' => [
...
'mongodb' => [
'driver' => 'mongodb',
'table' => 'cache', // name it as you wish
'connection' => 'mongodb',
],
],
Add the mongodb database connection in config/database.php
'connections' => [
...
'mongodb' => [
'driver' => 'mongodb',
'dsn' => env('MONGODB_DSN'),
'database' => env('MONGODB_DATABASE'),
],
],
Update your .env file and change the CACHE_DRIVER to mongodb
CACHE_DRIVER=mongodb
MONGODB_DSN=mongodb://localhost:27017/laravel
MONGODB_DATABASE=laravel
Advantages
-
This driver uses the MongoDB TTL indexes meaning when a cache key expires it will be automatically deleted.
-
This way, the collection's size will remain around the size you expect and won't get falsely filled with unused data.
-
The package automatically adds a migration which creates the index by running a mongodb command.
-
This package also registers two new commands:
php artisan mongodb:cache:indexand
php artisan mongodb:cache:dropindex
Warning
This cache driver is not compatible with other cache drivers because it encodes the data differently. If you are using another mongodb cache driver at the moment make sure you set a new collection for this one.
Enjoy!
ebethus/mongodb-laravel-cache 适用场景与选型建议
ebethus/mongodb-laravel-cache 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 27 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 06 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 ebethus/mongodb-laravel-cache 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ebethus/mongodb-laravel-cache 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 27
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-06-30