PHPackages                             bilulanlv/think-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. bilulanlv/think-cache

ActiveLibrary[Caching](/categories/caching)

bilulanlv/think-cache
=====================

Thinkphp8提取的Think-cache组件

v1.0.9(2y ago)6597↓100%1[2 issues](https://github.com/bilulanlv/think-cache/issues)MITPHPPHP &gt;=8.0.0

Since Apr 16Pushed 2y ago1 watchersCompare

[ Source](https://github.com/bilulanlv/think-cache)[ Packagist](https://packagist.org/packages/bilulanlv/think-cache)[ RSS](/packages/bilulanlv-think-cache/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (5)Used By (0)

说明
--

[](#说明)

由于[think-cache](https://github.com/top-think/think-cache)官方放弃了更新，且不支持php 8及以上，当使用ThinkORM做缓存时，如果使用webman的Cache类，tag功能无法使用。

故本项目提取自ThinkPHP 8最新的Cache模块，完美适配ThinkORM的缓存操作，以及字段缓存，tag和其他所有方法。

详细情况请查看[ThinkPHP8官方缓存文档](https://doc.thinkphp.cn/v8_0/caches.html)。

安装
--

[](#安装)

```
composer require bilulanlv/think-cache
```

配置文件
----

[](#配置文件)

配置文件自动安装路径在 config/plugin/bilulanlv/think-cache/app.php

```
// 如果ThinkORM需要使用缓存，请取消注释，或者在其他合适的地方引入
//\think\facade\Db::setCache(new \Bilulanlv\ThinkCache\CacheManager());

return [
    // 默认缓存驱动
    'default' => 'redis',
    // 缓存连接方式配置
    'stores'  => [
        // redis缓存
        'redis' => [
            // 驱动方式
            'type' => 'redis',
            // 服务器地址
            'host' => '127.0.0.1',
            // 缓存前缀
            'prefix' => 'cache',
            // 默认缓存有效期 0表示永久缓存
            'expire'     => 0,
            // think-cache官方没有这个参数，由于生成的tag键默认不过期，如果tag键数量很大，避免长时间占用内存，可以设置一个超过其他缓存的过期时间，0为不设置
            'tag_expire' => 86400 * 7,
            // 缓存标签前缀
            'tag_prefix' => 'tag:',
        ],
        // 文件缓存
        'file' => [
            // 驱动方式
            'type' => 'file',
            // 设置不同的缓存保存目录
            'path' => runtime_path() . '/file/',
        ],
    ],
];
```

使用说明
----

[](#使用说明)

```
use Bilulanlv\ThinkCache\facade\ThinkCache;

ThinkCache::set('name', $value, 3600);
ThinkCache::remember('start_time', time());
ThinkCache::tag('tag')->set('name1','value1');
ThinkCache::tag('tag')->clear();

UserModel::where('id', 1)->cache($cache['key'], $cache['expire'], $cache['tag'])->find();
```

###  Health Score

26

↓

LowBetter than 43% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~3 days

Total

4

Last Release

744d ago

### Community

Maintainers

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

---

Top Contributors

[![bilulanlv](https://avatars.githubusercontent.com/u/90918529?v=4)](https://github.com/bilulanlv "bilulanlv (21 commits)")

### Embed Badge

![Health badge](/badges/bilulanlv-think-cache/health.svg)

```
[![Health](https://phpackages.com/badges/bilulanlv-think-cache/health.svg)](https://phpackages.com/packages/bilulanlv-think-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/adapter-common

Common classes for PSR-6 adapters

11124.4M37](/packages/cache-adapter-common)[cache/array-adapter

A PSR-6 cache implementation using a php array. This implementation supports tags

548.3M151](/packages/cache-array-adapter)[cache/redis-adapter

A PSR-6 cache implementation using Redis (PhpRedis). This implementation supports tags

523.9M27](/packages/cache-redis-adapter)[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)[neos/cache

Neos Cache Framework

102.0M31](/packages/neos-cache)

PHPackages © 2026

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