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

Abandoned → [soupmix/cache](/?search=soupmix%2Fcache)ArchivedLibrary[Caching](/categories/caching)

soupmix/cache-base
==================

Provides framework agnostic implementation of PSR-16 Simple Cache Interface

1.0(4y ago)49733MITPHPPHP ^7.3 | ^8.0

Since Jun 13Pushed 4y ago1 watchersCompare

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

READMEChangelog (8)Dependencies (1)Versions (9)Used By (3)

Soupmix Cache API
-----------------

[](#soupmix-cache-api)

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.

#### 1.1 Redis

[](#11-redis)

##### Source Code

[](#source-code)

See [Github Repository](https://github.com/soupmix/cache-redis)

##### Installation

[](#installation)

```
$ composer require soupmix/cache-redis "~0.3"
```

##### 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)

##### Source Code

[](#source-code-1)

See [Github Repository](https://github.com/soupmix/cache-memcached)

##### Installation

[](#installation-1)

```
$ composer require soupmix/cache-memcached "~0.3"
```

##### 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)

##### Source Code

[](#source-code-2)

See [Github Repository](https://github.com/soupmix/cache-apcu)

##### Installation

[](#installation-2)

```
$ composer require soupmix/cache-apcu "~0.2"
```

##### Usage

[](#usage)

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

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

### 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 array(2) {
           ["my_key_1"]=>
            bool(true)
           ["my_key_2"]=>
            bool(true)
         }
 */
```

### 9. Increment a value atomically in the cache by its step value, which defaults to 1.

[](#9-increment-a-value-atomically-in-the-cache-by-its-step-value-which-defaults-to-1)

```
$cache->increment($key, $step);
```

**@param string $key**: The cache item key

**@param integer $step**: The value to increment by, defaulting to 1

@return int|bool The new value on success and false on failure

```
$cache->increment('counter', 1);
// returns int(1)
$cache->increment('counter', 1);
// returns int(2)
```

#### Important Note:

[](#important-note)

Memcached does not increments the keys that's not been set before. For Memcached you must set key with the default value.

```
$cache->set('counter', 0);
// returns bool(true)
$cache->increment('counter', 1);
// returns int(1)
```

### 10. Decrement a value atomically in the cache by its step value, which defaults to 1

[](#10-decrement-a-value-atomically-in-the-cache-by-its-step-value-which-defaults-to-1)

```
$cache->decrement($key, $step);
```

**@param string $key**: The cache item key

**@param integer $step**: The value to decrement by, defaulting to 1

```
$cache->decrement('counter', 1);
// returns int(1)
$cache->decrement('counter', 1);
// returns int(0)
```

#### Important Note 1:

[](#important-note-1)

Memcached does not decrements the keys that's not been set before. For Memcached you must set key with the default value.

```
$cache->set('counter', 1);
// returns bool(true)
$cache->decrement('counter', 1);
// returns int(0)
```

#### Important Note 2:

[](#important-note-2)

Memcached does not decrements to negative values and stops at zero where Redis can decrement to negative values and goes setting -1,-2, etc...

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

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

@return bool True on success and false on failure

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

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity73

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

Recently: every ~459 days

Total

8

Last Release

1823d ago

Major Versions

0.2.2 → 1.02021-06-26

PHP version history (3 changes)0.1PHP &gt;=5.5

0.2.1PHP ~5.6|~7.0|~7.1

1.0PHP ^7.3 | ^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 (19 commits)")

---

Tags

interfacecacheadapterssimplecache

### Embed Badge

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

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

###  Alternatives

[amnuts/opcache-gui

A clean, effective and responsive interface for Zend OPcache, with real(ish)-time monitoring, filtering and the ability to invalidate files

1.4k4.8M17](/packages/amnuts-opcache-gui)[laminas/laminas-cache

Caching implementation with a variety of storage options, as well as codified caching strategies for callbacks, classes, and output

1067.2M145](/packages/laminas-laminas-cache)[sabre/cache

Simple cache abstraction layer implementing PSR-16

551.3M4](/packages/sabre-cache)[voku/simple-cache

Simple Cache library

322.6M9](/packages/voku-simple-cache)[gilbitron/php-simplecache

A simple script for caching 3rd party API calls in PHP.

26038.0k5](/packages/gilbitron-php-simplecache)[graham-campbell/bounded-cache

A Bounded TTL PSR-16 Cache Implementation

112.1M10](/packages/graham-campbell-bounded-cache)

PHPackages © 2026

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