PHPackages                             1ff/laravel-mongodb-cache - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. 1ff/laravel-mongodb-cache

ActiveLibrary[Caching](/categories/caching)

1ff/laravel-mongodb-cache
=========================

A mongodb cache driver for laravel

7.0.0(2y ago)1659.7k↓27.3%10[2 issues](https://github.com/1FF/laravel-mongodb-cache/issues)[3 PRs](https://github.com/1FF/laravel-mongodb-cache/pulls)MITPHPPHP ^8.2|^8.3

Since Aug 16Pushed 12mo ago6 watchersCompare

[ Source](https://github.com/1FF/laravel-mongodb-cache)[ Packagist](https://packagist.org/packages/1ff/laravel-mongodb-cache)[ RSS](/packages/1ff-laravel-mongodb-cache/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (45)Used By (0)

Laravel Mongodb Cache driver
============================

[](#laravel-mongodb-cache-driver)

A MongoDB cache driver for Laravel

**Laravel
Version****Package
Version****Install using
this command**11.x7.x.xcomposer require 1ff/laravel-mongodb-cache:^7.010.x6.x.xcomposer require 1ff/laravel-mongodb-cache:^6.09.x5.x.xcomposer require 1ff/laravel-mongodb-cache:^5.08.x4.x.xcomposer require 1ff/laravel-mongodb-cache:^4.17.x3.x.xcomposer require 1ff/laravel-mongodb-cache:^3.15.8.x, 6.x2.12.xcomposer require 1ff/laravel-mongodb-cache:~2.12.05.7.x2.11.xcomposer require 1ff/laravel-mongodb-cache:~2.11.0Installation
------------

[](#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
----------

[](#advantages)

- This driver uses the [MongoDB TTL indexes](https://docs.mongodb.com/manual/core/index-ttl/) 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
-------

[](#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!
------

[](#enjoy)

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity90

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~61 days

Recently: every ~102 days

Total

41

Last Release

385d ago

Major Versions

v3.x-dev → v4.x-dev2024-03-14

4.1.1 → v5.x-dev2024-03-14

5.0.1 → 6.0.42024-03-14

6.0.4 → v7.x-dev2024-03-14

v2.11.2.x-dev → v6.0.52025-04-25

PHP version history (2 changes)6.0.0PHP ^8.1

v7.x-devPHP ^8.2|^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/35f534b679e79a43f872d066e060600f317f93fd423e6e017cb3ab7a266cbf94?d=identicon)[vcrazy](/maintainers/vcrazy)

---

Top Contributors

[![spont4e](https://avatars.githubusercontent.com/u/10523455?v=4)](https://github.com/spont4e "spont4e (14 commits)")[![t1sh0o](https://avatars.githubusercontent.com/u/3911728?v=4)](https://github.com/t1sh0o "t1sh0o (11 commits)")[![vcrazy](https://avatars.githubusercontent.com/u/545351?v=4)](https://github.com/vcrazy "vcrazy (7 commits)")[![tuseto](https://avatars.githubusercontent.com/u/9108143?v=4)](https://github.com/tuseto "tuseto (4 commits)")[![koprinski](https://avatars.githubusercontent.com/u/28507711?v=4)](https://github.com/koprinski "koprinski (2 commits)")

### Embed Badge

![Health badge](/badges/1ff-laravel-mongodb-cache/health.svg)

```
[![Health](https://phpackages.com/badges/1ff-laravel-mongodb-cache/health.svg)](https://phpackages.com/packages/1ff-laravel-mongodb-cache)
```

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k8.2M51](/packages/spatie-laravel-responsecache)[genealabs/laravel-model-caching

Automatic caching for Eloquent models.

2.4k4.8M26](/packages/genealabs-laravel-model-caching)[mikebronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k127.1k1](/packages/mikebronner-laravel-model-caching)[laragear/cache-query

Remember your query results using only one method. Yes, only one.

272122.8k](/packages/laragear-cache-query)[monospice/laravel-redis-sentinel-drivers

Redis Sentinel integration for Laravel and Lumen.

103830.5k](/packages/monospice-laravel-redis-sentinel-drivers)[iazaran/smart-cache

Smart Cache is a caching optimization package designed to enhance the way your Laravel application handles data caching. It intelligently manages large data sets by compressing, chunking, or applying other optimization strategies to keep your application performant and efficient.

2057.2k](/packages/iazaran-smart-cache)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
