定制 1ff/laravel-mongodb-cache 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

1ff/laravel-mongodb-cache

最新稳定版本:7.0.0

Composer 安装命令:

composer require 1ff/laravel-mongodb-cache

包简介

A mongodb cache driver for laravel

README 文档

README

A MongoDB cache driver for Laravel

Laravel
Version
Package
Version
Install using
this command
11.x 7.x.x composer require 1ff/laravel-mongodb-cache:^7.0
10.x 6.x.x composer require 1ff/laravel-mongodb-cache:^6.0
9.x 5.x.x composer require 1ff/laravel-mongodb-cache:^5.0
8.x 4.x.x composer require 1ff/laravel-mongodb-cache:^4.1
7.x 3.x.x composer require 1ff/laravel-mongodb-cache:^3.1
5.8.x, 6.x 2.12.x composer require 1ff/laravel-mongodb-cache:~2.12.0
5.7.x 2.11.x composer require 1ff/laravel-mongodb-cache:~2.11.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:index
    

    and

      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!

统计信息

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

GitHub 信息

  • Stars: 16
  • Watchers: 6
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-08-16