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

ActiveLibrary[Caching](/categories/caching)

robinn/cache
============

Simple cache for PHP with support for Redis, Memcached, APCu and Files.

2.6.4(1mo ago)849511MITPHPPHP &gt;=8.4CI passing

Since May 25Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/RobiNN1/Cache)[ Packagist](https://packagist.org/packages/robinn/cache)[ RSS](/packages/robinn-cache/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (26)Used By (1)

Simple cache
============

[](#simple-cache)

Simple cache for PHP with support for Redis, Memcached, APCu, and Files.

[![Visitor Badge](https://camo.githubusercontent.com/9ddb07f0d53eb71dc6c13384c0d6ea705c3bba0f0ea7cbe7738e6e3a219539e1/68747470733a2f2f76697369746f722d62616467652e6c616f62692e6963752f62616467653f706167655f69643d526f62694e4e312e4361636865)](https://camo.githubusercontent.com/9ddb07f0d53eb71dc6c13384c0d6ea705c3bba0f0ea7cbe7738e6e3a219539e1/68747470733a2f2f76697369746f722d62616467652e6c616f62692e6963752f62616467653f706167655f69643d526f62694e4e312e4361636865)

Installation
------------

[](#installation)

```
composer require robinn/cache

```

Usage
-----

[](#usage)

```
$cache = new RobiNN\Cache\Cache([
    // Available config options
    'storage'   => 'file', // apcu|file|memcached|redis
    'file'      => [
        'path' => __DIR__.'/cache', // The path to the folder containing the cached content.
        //'secret' => 'secret_key', // For securing file names (optional).
        //'remove_expired' => true, // Automatically remove all expired keys (it can affect performance) (optional).
    ],
    'redis'     => [
        'host' => '127.0.0.1', // Optional when a path is specified.
        'port' => 6379, // Optional when the default port is used.
        //'database' => 0, // Default database (optional).
        //'username' => '', // ACL - requires Redis >= 6.0 (optional).
        //'password' => '', // Optional.
        //'path' => '/var/run/redis/redis-server.sock', // Unix domain socket (optional).
    ],
    'memcached' => [
        'host' => '127.0.0.1', // Optional when a path is specified.
        'port' => 11211, // Optional when the default port is used.
        //'path' => '/var/run/memcached/memcached.sock', // Unix domain socket (optional).
        //'sasl_username' => '', // SASL auth (optional).
        //'sasl_password' => '', // SASL auth (optional).
    ],
]);

$key = 'item-key';

if ($cache->exists($key)) {
    $data = $cache->get($key);
} else {
    $data = 'item-value';
    $cache->set($key, $data);
}

// The above code can also be shortened to one line
$data = $cache->remember($key, 'item-value');

print_r($data); // item-value
```

Methods
-------

[](#methods)

NameReturnDescriptionisConnectedboolCheck connection.existsboolCheck if the data is cached.setboolSave data to cache.getmixedGet data by key.remembermixedGet the data or store if it is not cached.deleteboolDelete data by key.flushboolDelete all data from cache.Requirements
------------

[](#requirements)

- PHP &gt;= 8.2

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance75

Regular maintenance activity

Popularity22

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity76

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

Recently: every ~271 days

Total

25

Last Release

46d ago

PHP version history (3 changes)2.0.0PHP &gt;=8.1

2.5.0PHP &gt;=8.2

2.6.4PHP &gt;=8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/2742c8966fe1d84d510cf580119bd593ade8188605e218be398014846132be31?d=identicon)[RobiNN1](/maintainers/RobiNN1)

---

Top Contributors

[![RobiNN1](https://avatars.githubusercontent.com/u/11664877?v=4)](https://github.com/RobiNN1 "RobiNN1 (123 commits)")

---

Tags

cachecachingfilememcachephpredisrediscachefilememcachedmemcache

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[desarrolla2/cache

Provides an cache interface for several adapters Apc, Apcu, File, Mongo, Memcache, Memcached, Mysql, Mongo, Redis is supported.

1322.5M47](/packages/desarrolla2-cache)[robinn/phpcacheadmin

A web dashboard for your favorite caching system.

4441.1k1](/packages/robinn-phpcacheadmin)[matomo/cache

PHP caching library based on Doctrine cache

38854.1k4](/packages/matomo-cache)[ihor/cachalot

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

2528.1k](/packages/ihor-cachalot)[garyr/memento

Lightweight cache library

186.6k1](/packages/garyr-memento)

PHPackages © 2026

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