PHPackages                             mongdch/mon-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. mongdch/mon-cache

ActiveLibrary[Caching](/categories/caching)

mongdch/mon-cache
=================

The PSR-16 simple cache utils.

1.1.0(5mo ago)21383MITPHPPHP &gt;=7.0

Since Sep 17Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/MonGDCH/mon-cache)[ Packagist](https://packagist.org/packages/mongdch/mon-cache)[ Docs](http://gdmon.com/)[ RSS](/packages/mongdch-mon-cache/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (13)Used By (3)

mon-cache
=========

[](#mon-cache)

一个基于`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框架支持

[](#gaia框架支持)

`composer`安装后执行`php gaia vendor:publish mon\cache`即可

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance72

Regular maintenance activity

Popularity14

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 72% of commits — single point of failure

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 ~107 days

Recently: every ~97 days

Total

12

Last Release

157d ago

PHP version history (2 changes)1.0.0PHP &gt;=7.0.0

1.0.10PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/f72e67ce10f7cfef428bc70ce1ec7411eb16bae10edc2cc5277b765284a46c39?d=identicon)[MonGDCH](/maintainers/MonGDCH)

---

Top Contributors

[![MonGDCH](https://avatars.githubusercontent.com/u/19282393?v=4)](https://github.com/MonGDCH "MonGDCH (18 commits)")[![monton-gif](https://avatars.githubusercontent.com/u/53856623?v=4)](https://github.com/monton-gif "monton-gif (7 commits)")

---

Tags

cachepsr-16

### Embed Badge

![Health badge](/badges/mongdch-mon-cache/health.svg)

```
[![Health](https://phpackages.com/badges/mongdch-mon-cache/health.svg)](https://phpackages.com/packages/mongdch-mon-cache)
```

###  Alternatives

[laminas/laminas-cache

Caching implementation with a variety of storage options, as well as codified caching strategies for callbacks, classes, and output

1076.9M130](/packages/laminas-laminas-cache)[cache/simple-cache-bridge

A PSR-6 bridge to PSR-16. This will make any PSR-6 cache compatible with SimpleCache.

423.1M27](/packages/cache-simple-cache-bridge)[sabre/cache

Simple cache abstraction layer implementing PSR-16

541.2M3](/packages/sabre-cache)[chillerlan/php-cache

A psr/simple-cache implementation. PHP 8.1+

15211.8k11](/packages/chillerlan-php-cache)[webarchitect609/bitrix-cache

Comfortable fluent interface for Bitrix cache. Anti-stampede cache protection.

2831.2k8](/packages/webarchitect609-bitrix-cache)[codeigniter4/cache

PSR-6 and PSR-16 Cache Adapters for CodeIgniter 4

1320.1k](/packages/codeigniter4-cache)

PHPackages © 2026

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