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

ActiveLibrary[Caching](/categories/caching)

hutong/cache
============

数据缓存

v1.0.0(8y ago)0367MITPHPPHP &gt;=7.0.0

Since May 11Pushed 4y ago1 watchersCompare

[ Source](https://github.com/HuTong/cache)[ Packagist](https://packagist.org/packages/hutong/cache)[ RSS](/packages/hutong-cache/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (2)Used By (0)

cache
=====

[](#cache)

数据缓存

配置
--

[](#配置)

### File 缓存

[](#file-缓存)

```
include './vendor/autoload.php';

$config = array(
    'default' => array(
        'type' => 'File',
        'path' => '/var/www/test/cache/',
        'prefix' => '',
    ),
    'redis' => array(
        'type' => 'Redis',
    	'host' => '127.0.0.1',
    	'port' => '6379',
    	'password' => '123456',
    	'prefix' => 'web.',
    ),
);

$cache = new HuTong\Cache\Storage($config);

$val = $cache->store()->increment('getVal');
var_dump($val);
$val = $cache->store('redis')->increment('getVal');
var_dump($val);

输出：
int(1)
int(1)

```

```
$val = $cache->store()->set('getVal','33');

$val = $cache->store()->get('getVal');

3分钟过期
$val = $cache->store()->expire('getVal',33);

33秒钟过期
$val = $cache->store()->expire('getVal',33,1);

$val = $cache->store()->del('getVal');

$val = $cache->store()->increment('getVal');

$val = $cache->store()->decrement('getVal');

$val = $cache->store()->flush();

```

学习交流群
=====

[](#学习交流群)

630730920

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Unknown

Total

1

Last Release

2973d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8066878?v=4)[HuTong](/maintainers/HuTong)[@HuTong](https://github.com/HuTong)

---

Top Contributors

[![HuTong](https://avatars.githubusercontent.com/u/8066878?v=4)](https://github.com/HuTong "HuTong (7 commits)")

### Embed Badge

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

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

###  Alternatives

[beryllium/cachebundle

Provides an interface to Memcache for Symfony2 applications

32136.0k](/packages/beryllium-cachebundle)

PHPackages © 2026

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