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

AbandonedArchivedProject[Caching](/categories/caching)

jmatosp/tumbleweed-cache
========================

PHP caching implementation of PSR-6

1.2.4(10y ago)1413.4k1[1 issues](https://github.com/jmatosp/TumbleweedCache/issues)MITPHPPHP &gt;=5.6|&gt;=7.0

Since Jan 6Pushed 10y ago2 watchersCompare

[ Source](https://github.com/jmatosp/TumbleweedCache)[ Packagist](https://packagist.org/packages/jmatosp/tumbleweed-cache)[ RSS](/packages/jmatosp-tumbleweed-cache/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (3)Dependencies (5)Versions (9)Used By (0)

TumbleweedCache
===============

[](#tumbleweedcache)

[![Build Status](https://camo.githubusercontent.com/ac1a7da9250f54c9c55406b4aa750b6384ae321f47d28cf43e7a894c9ee09eba/68747470733a2f2f7472617669732d63692e6f72672f6a6d61746f73702f54756d626c657765656443616368652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/jmatosp/TumbleweedCache) [![Coverage Status](https://camo.githubusercontent.com/c7e29348d3b16da831c204da528b31921ecc594b6f0fad83137604143af11fe4/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6a6d61746f73702f54756d626c657765656443616368652f62616467652e7376673f6272616e63683d6d617374657226736572766963653d676974687562)](https://coveralls.io/github/jmatosp/TumbleweedCache?branch=master) [![Latest Stable Version](https://camo.githubusercontent.com/aa698b6637c57d5de6e75ed1808c5227962ff4686e06e806469697e1953b80df/68747470733a2f2f706f7365722e707567782e6f72672f6a6d61746f73702f74756d626c65776565642d63616368652f762f737461626c65)](https://packagist.org/packages/jmatosp/tumbleweed-cache)

*PHP Caching - PSR-6 implementation*

This library provides Calling Libraries abstract cache services.

Implementations for well known cache infrastructure, clever cache using multi-level/failover cache and clustered like cache.

Drivers available: *APCu*, *Redis*, *Files*, *Memcached*, *Memory*, *2 Level Cache*

All drivers where tested using PHPUnit and a great [3rd party testing suite for PSR-6](https://github.com/php-cache/integration-tests)

Install
=======

[](#install)

```
composer require jmatosp/tumbleweed-cache

```

Usage
=====

[](#usage)

Simple to use, Tumbleweed Cache will try to use one of the available drivers APCu, Redis or Files

```
$cache = CacheFactory::make();
$item = $cache->getItem('my_key')
            ->set('value')
            ->expiresAfter(60);
$cache->save($item);
echo $cache->getItem('my_key')->get();
// will output "value"

```

or not using *CacheFactory* and instantiating APCu directly

```
$cache = new APCuCache();
$cache->getItem('hello')->set('value');
echo $cache->getItem('hello')->get();   // output: "value"

```

You can specify the cache implementation to use:

**APCu**

This driver supports both apc and apcu, works with HHVM (legacy), apcu only PHP7 and apc/apcu on PHP5.6

```
$cache = CacheFactory::make(CacheFactory::APCU);
$item = $cache->getItem('my_key')->set('value');
$cache->save($item);
echo $cache->getItem('my_key')->get();
// will output "value"

```

**Redis**

You can use the factory to create a Redis cache instance, factory will try to connect to default port on localhost, or you can provide a connection as in this example.

```
$redis = new Redis();
$redis->connect('127.0.0.1');
$cache = CacheFactory::make(CacheFactory::REDIS, $redis);
$item = $cache->getItem('my_key')->set('value');
$cache->save($item);
echo $cache->getItem('my_key)->get();
// will output "value"

```

**Files**

File base cache interface, fast and uses /tmp directory. Cache factory will check if TMP dir is writable and throw and exception if not.

```
$cache = CacheFactory::make(CacheFactory::FILE);
$item = $cache->getItem('my_key')->set('value');
$cache->save($item);
echo $cache->getItem('my_key)->get();
// will output "value"

```

**Memcache**

```
$memcached = new Memcached('my_app_ip');
$memcached->addServer('localhost', 11211);
$cache = CacheFactory::make(CacheFactory::MEMCACHED, $memcached);
$item = $cache->getItem('my_key')->set('value');
$cache->save($item);
echo $cache->getItem('my_key)->get();
// will output "value"

```

**Two level**

Two level cache aims to use 2 cache repositories, as failover with two remote caches or a combination of one local to with faster access like APCu and one remote typically Redis or Memcached. Also good to work as a failover cache in case of the first one fails. Sample using APCu as first level (faster) and Redis second level (fast)

```
$localCache = CacheFactory::make(CacheFactory::APCU);
$remoteCache = CacheFactory::make(CacheFactory::REDIS);
$megaCache = CacheFactory::make(CacheFactory::TWO_LEVEL, $localCache, $remoteCache);
$item = $cache->getItem('my_key')->set('value');
$cache->save($item);
echo $cache->getItem('my_key')->get();
// will output "value"

```

Cache Factory
=============

[](#cache-factory)

Cache factory enables creation to different type of cache infrastructure with an easy interface.

It has a builtin auto-discovery that will try to find the fastest one available, to use the auto-discovery simply call the factory without parameters:

```
$cacheService = CacheFactory::make();

```

Auto-discovery will try to use cache infrastructure by this order: APCu, APC, File, Redis

PSR-6 Cache Interface
=====================

[](#psr-6-cache-interface)

All cache item pool implementations use PSR-6 interfaces, for details please visit [PHP-FIG PSR-6: Caching Interface](http://www.php-fig.org/psr/psr-6/)

Running tests
=============

[](#running-tests)

To run all test including integration you need:

- Redis - installed locally on standard port 127.0.0.1:6379
- APCu - edit your php.ini and add "apc.enable\_cli=1" after the extension loading to enable tests on APCu
- Memcached

Optionally you can run on the provided Vagrant box:

```
vagrant up
vagrant ssh
cd /vagrant
composer install
vendor/bin/phpunit

```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

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

Total

7

Last Release

3770d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/81049f1a27cc8f01ac7bc35e2b0d7806eaf352247422271af342ffe4dfee7241?d=identicon)[jmatosp](/maintainers/jmatosp)

---

Top Contributors

[![jmatosp](https://avatars.githubusercontent.com/u/4009404?v=4)](https://github.com/jmatosp "jmatosp (72 commits)")

---

Tags

rediscachepsr6apcmemcache

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[tedivm/stash

The place to keep your cache.

9824.8M124](/packages/tedivm-stash)[phpfastcache/phpfastcache

PHP Abstract Cache Class - Reduce your database call using cache system. Phpfastcache handles a lot of drivers such as Apc(u), Cassandra, CouchBase, Couchdb, Dynamodb, Firestore, Mongodb, Files, (P)redis, Leveldb, Memcache(d), Ravendb, Ssdb, Sqlite, Wincache, Xcache, Zend Data Cache.

2.4k5.0M130](/packages/phpfastcache-phpfastcache)[tedivm/stash-bundle

Incorporates the Stash caching library into Symfony.

841.4M16](/packages/tedivm-stash-bundle)[apix/cache

A thin PSR-6 cache wrapper with a generic interface to various caching backends emphasising cache taggging and indexing to Redis, Memcached, PDO/SQL, APC and other adapters.

114542.8k6](/packages/apix-cache)[sabre/cache

Simple cache abstraction layer implementing PSR-16

541.2M3](/packages/sabre-cache)[ihor/cachalot

Cache a lot in a proper way (APC, XCache, Memcached, Redis, Couchbase)

2528.1k](/packages/ihor-cachalot)

PHPackages © 2026

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