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

ActiveLibrary[Caching](/categories/caching)

ayhome/think-cache
==================

Cache Manager

2.0.9(1y ago)04Apache-2.0PHPPHP &gt;=7.1.0

Since Aug 28Pushed 1y agoCompare

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

READMEChangelog (1)Dependencies (3)Versions (3)Used By (0)

新增调整
====

[](#新增调整)

在php 8.2环境下，依赖的 opis/closure 包不支持 8.2，根据官方最新版本的更改了下，移出 该包。好像也不影响使用。

think-cache
===========

[](#think-cache)

用于PHP缓存管理（PHP 7.1+），支持`PSR-6`及`PSR-16`缓存规范。

主要特性包括：

- 支持多缓存通道设置及切换
- 支持缓存数据递增/递减
- 支持门面调用
- 内置File/Redis/Memcache/Memcached/Wincache
- 支持缓存标签
- 支持闭包数据
- 支持`PSR-6`及`PSR-16`缓存规范

安装
--

[](#安装)

```
composer require ayhome/think-cache

```

用法：
---

[](#用法)

```
use think\facade\Cache;

// 缓存配置
Cache::config([
	'default'	=>	'file',
	'stores'	=>	[
		'file'	=>	[
			'type'   => 'File',
			// 缓存保存目录
			'path'   => './cache/',
			// 缓存前缀
			'prefix' => '',
			// 缓存有效期 0表示永久缓存
			'expire' => 0,
		],
		'redis'	=>	[
			'type'   => 'redis',
			'host'   => '127.0.0.1',
			'port'   => 6379,
			'prefix' => '',
			'expire' => 0,
		],
	],
]);
// 设置缓存
Cache::set('val','value',600);
// 判断缓存是否设置
Cache::has('val');
// 获取缓存
Cache::get('val');
// 删除缓存
Cache::delete('val');
// 清除缓存
Cache::clear();
// 读取并删除缓存
Cache::pull('val');
// 不存在则写入
Cache::remember('val',10);

// 对于数值类型的缓存数据可以使用
// 缓存增+1
Cache::inc('val');
// 缓存增+5
Cache::inc('val',5);
// 缓存减1
Cache::dec('val');
// 缓存减5
Cache::dec('val',5);

// 使用缓存标签
Cache::tag('tag_name')->set('val','value',600);
// 删除某个标签下的缓存数据
Cache::tag('tag_name')->clear();
// 支持指定多个标签
Cache::tag(['tag1','tag2'])->set('val2','value',600);
// 删除多个标签下的缓存数据
Cache::tag(['tag1','tag2'])->clear();

// 使用多种缓存类型
$redis = Cache::store('redis');

$redis->set('var','value',600);
$redis->get('var');
```

更多内容可以参考 [https://www.kancloud.cn/manual/thinkphp6\_0/1037634](https://www.kancloud.cn/manual/thinkphp6_0/1037634)

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 76.3% 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 ~0 days

Total

3

Last Release

628d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0aad496bd3f3648f041ddebb82156f03473f73306ad0eb2193d9ceca7f17b806?d=identicon)[ayhome](/maintainers/ayhome)

---

Top Contributors

[![liu21st](https://avatars.githubusercontent.com/u/1111670?v=4)](https://github.com/liu21st "liu21st (29 commits)")[![ayhome](https://avatars.githubusercontent.com/u/490287?v=4)](https://github.com/ayhome "ayhome (5 commits)")[![evalor](https://avatars.githubusercontent.com/u/26944445?v=4)](https://github.com/evalor "evalor (2 commits)")[![AxiosLeo](https://avatars.githubusercontent.com/u/13862149?v=4)](https://github.com/AxiosLeo "AxiosLeo (1 commits)")[![ichynul](https://avatars.githubusercontent.com/u/10061650?v=4)](https://github.com/ichynul "ichynul (1 commits)")

### Embed Badge

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

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

###  Alternatives

[symfony/cache

Provides extended PSR-6, PSR-16 (and tags) implementations

4.2k348.9M2.5k](/packages/symfony-cache)[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.4M38](/packages/cache-adapter-common)[cache/cache

Library of all the php-cache adapters

2712.7M22](/packages/cache-cache)[cache/filesystem-adapter

A PSR-6 cache implementation using filesystem. This implementation supports tags

705.8M82](/packages/cache-filesystem-adapter)[cache/array-adapter

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

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

PHPackages © 2026

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