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

ActiveLibrary[Caching](/categories/caching)

soupmix/cache
=============

Provides framework agnostic implementation of PSR-16 Simple Cache Interface

1.1(3y ago)07MITPHPPHP ^8.0

Since Jun 26Pushed 3y ago1 watchersCompare

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

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

Soupmix SimpleCache API
-----------------------

[](#soupmix-simplecache-api)

[![Build Status](https://camo.githubusercontent.com/027df07fed207b754fa9c455024eb1cb6afddf8815b86bb7c841a06679cbb7fb/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f736f75706d69782f63616368652f6261646765732f6275696c642e706e673f623d6d61696e)](https://scrutinizer-ci.com/g/soupmix/cache/build-status/main) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/cf2548ff80836f915f730b3e17bdfaa83aa8b10c12b8c5537658cd7ccb7e611c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f736f75706d69782f63616368652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d61696e)](https://scrutinizer-ci.com/g/soupmix/cache/?branch=main) [![Code Coverage](https://camo.githubusercontent.com/a3bca798ef8479ac92cad2a98e73e4c3dd318f3725418401c45fe92b7aa748f7/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f736f75706d69782f63616368652f6261646765732f636f7665726167652e706e673f623d6d61696e)](https://scrutinizer-ci.com/g/soupmix/cache/?branch=main)

Soupmix Cache provides framework-agnostic implementation of [PSR-16 Simple Cache Interface](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-16-simple-cache.md).

### 1. Install and Connect to Service

[](#1-install-and-connect-to-service)

It's recommended that you use [Composer](https://getcomposer.org/) to install Soupmix Cache Adaptors.

##### Installation

[](#installation)

```
$ composer require soupmix/cache
```

#### 1.1 Redis

[](#11-redis)

##### Connect to Redis (single instance) service

[](#connect-to-redis-single-instance-service)

```
require_once '/path/to/composer/vendor/autoload.php';

$rConfig = ['host'=> "127.0.0.1"];
$handler = new Redis();
$handler->connect(
    $rConfig['host']
);

$cache = new Soupmix\Cache\RedisCache($handler);
```

#### 1.2 Memcached

[](#12-memcached)

##### Connect to Memcached service

[](#connect-to-memcached-service)

```
require_once '/path/to/composer/vendor/autoload.php';

$config = [
    'bucket' => 'test',
    'hosts'   => ['127.0.0.1'],
;
$handler = new Memcached($config['bucket']);
$handler->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
$handler->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
if (!count($handler->getServerList())) {
    $hosts = [];
    foreach ($config['hosts'] as $host) {
        $hosts[] = [$host, 11211];
    }
    $handler->addServers($hosts);
}

$cache = new Soupmix\Cache\MemcachedCache($handler);
```

#### 1.3 APCu

[](#13-apcu)

##### Usage

[](#usage)

```
require_once '/path/to/composer/vendor/autoload.php';

$cache = new Soupmix\Cache\APCUCache();
```

#### 1.4 PHP Array

[](#14-php-array)

##### Usage

[](#usage-1)

```
require_once '/path/to/composer/vendor/autoload.php';

$cache = new Soupmix\Cache\ArrayCache();
```

### 2. Persist data in the cache, uniquely referenced by a key with an optional expiration TTL time.

[](#2-persist-data-in-the-cache-uniquely-referenced-by-a-key-with-an-optional-expiration-ttl-time)

```
$cache->set($key, $value, $ttl);
```

**@param string $key**: The key of the item to store

**@param mixed $value**: The value of the item to store

**@param null|integer|DateInterval $ttl**: Optional. The TTL value of this item. If no value is sent and the driver supports TTL then the library may set a default value for it or let the driver take care of that. Predefined DataIntervals: TTL\_MINUTE, TTL\_HOUR, TTL\_DAY.

@return bool True on success and false on failure

```
$cache->set('my_key, 'my_value', TTL_DAY);

// returns bool(true)
```

### 3. Determine whether an item is present in the cache.

[](#3-determine-whether-an-item-is-present-in-the-cache)

```
$cache->has($key);
```

**@param string $key**: The unique cache key of the item to delete

@return bool True on success and false on failure

```
$cache->has('my_key');

// returns bool(true)
```

### 4. Fetch a value from the cache.

[](#4-fetch-a-value-from-the-cache)

```
$cache->get($key, default=null);
```

**@param string $key**: The unique key of this item in the cache @return mixed The value of the item from the cache, or null in case of cache miss

```
$cache->get('my_key');

// returns  string(8) "my_value"
```

### 5. Delete an item from the cache by its unique key

[](#5-delete-an-item-from-the-cache-by-its-unique-key)

```
$cache->delete($key);
```

**@param string $key**: The unique cache key of the item to delete

@return bool True on success and false on failure

```
$cache->delete('my_key');

// returns bool(true)
```

### 6. Persisting a set of key =&gt; value pairs in the cache, with an optional TTL.

[](#6-persisting-a-set-of-key--value-pairs-in-the-cache-with-an-optional-ttl)

```
$cache->setMultiple(array $items);
```

**@param array|Traversable $items**: An array of key =&gt; value pairs for a multiple-set operation.

**@param null|integer|DateInterval $ttl**: Optional. The amount of seconds from the current time that the item will exist in the cache for. If this is null then the cache backend will fall back to its own default behaviour.

@return bool True on success and false on failure

```
$items = ['my_key_1'=>'my_value_1', 'my_key_2'=>'my_value_2'];
$cache->setMultiple($items);

// returns bool(true)
```

### 7. Obtain multiple cache items by their unique keys.

[](#7-obtain-multiple-cache-items-by-their-unique-keys)

```
$cache->getMultiple($keys, $default=null);
```

**@param array|Traversable $keys**: A list of keys that can obtained in a single operation.

@return array An array of key =&gt; value pairs. Cache keys that do not exist or are stale will have a value of null.

```
$keys = ['my_key_1', 'my_key_2'];
$cache->getMultiple($keys);
/*
returns array(2) {
          ["my_key_1"]=>
          string(3) "my_value_1"
          ["my_key_2"]=>
          string(3) "my_value_2"
        }
*/
```

### 8. Delete multiple cache items in a single operation.

[](#8-delete-multiple-cache-items-in-a-single-operation)

```
$cache->deleteMultiple($keys);
```

**@param array|Traversable $keys**: The array of string-based keys to be deleted

@return bool True on success and false on failure

```
$keys = ['my_key_1', 'my_key_2'];
$cache->deleteMultiple($keys);
 /*
 returns bool(true)
 */
```

### 9. Wipe clean the entire cache's keys (Flush)

[](#9-wipe-clean-the-entire-caches-keys-flush)

@return bool True on success and false on failure

```
$cache->clear();
// returns bool(true)
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

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

Total

2

Last Release

1242d ago

PHP version history (2 changes)1.0PHP ^7.3|^8.0

1.1PHP ^8.0

### Community

Maintainers

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

---

Top Contributors

[![mkorkmaz](https://avatars.githubusercontent.com/u/585601?v=4)](https://github.com/mkorkmaz "mkorkmaz (14 commits)")

---

Tags

arrayrediscachememcachedapcuadapterssimplecache

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[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

The place to keep your cache.

9824.8M124](/packages/tedivm-stash)[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)[sabre/cache

Simple cache abstraction layer implementing PSR-16

541.2M3](/packages/sabre-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)

PHPackages © 2026

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