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

ActiveLibrary[Caching](/categories/caching)

rundiz/simple-cache
===================

The simple and easy PHP cache drivers for cache any PHP data type.

3.1.0(1y ago)5137MITPHPPHP &gt;=8.0

Since Apr 22Pushed 6mo ago2 watchersCompare

[ Source](https://github.com/Rundiz/simple-cache)[ Packagist](https://packagist.org/packages/rundiz/simple-cache)[ RSS](/packages/rundiz-simple-cache/feed)WikiDiscussions version3.1 Synced 3w ago

READMEChangelog (7)Dependencies (1)Versions (9)Used By (0)

Simple Cache
============

[](#simple-cache)

The simple and easy PHP cache drivers for cache any PHP data type. It is implemented PSR-16.

[![Latest Stable Version](https://camo.githubusercontent.com/af6a96f55dfc0358d6cb145f66d6c80996c398c68a9f68b89ac9e859a6b65cb6/68747470733a2f2f706f7365722e707567782e6f72672f72756e64697a2f73696d706c652d63616368652f762f737461626c65)](https://packagist.org/packages/rundiz/simple-cache)[![License](https://camo.githubusercontent.com/2141087b594ecbff3e3d009b2c954720dd91d25c69688b43374a53defcd2d62f/68747470733a2f2f706f7365722e707567782e6f72672f72756e64697a2f73696d706c652d63616368652f6c6963656e7365)](https://packagist.org/packages/rundiz/simple-cache)[![Total Downloads](https://camo.githubusercontent.com/10b0e822bc9f760a5d2f9e205533ff17710ce28f772c2e9de500e90e6b79be9f/68747470733a2f2f706f7365722e707567782e6f72672f72756e64697a2f73696d706c652d63616368652f646f776e6c6f616473)](https://packagist.org/packages/rundiz/simple-cache)

Tested up to PHP 8.5.

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

[](#installation)

Make sure that you have [Composer](http://getcomposer.org/) installed and then run the following command.

```
composer require rundiz/simple-cache

```

Example
-------

[](#example)

We currently support APC, APCu, Memcache, Memcached, File system drivers. These are how to initialize for each driver class.

```
// For Memcache driver
$memcache = new \Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");
$SimpleCache = new \Rundiz\SimpleCache\Drivers\Memcached($memcache);
unset($memcache);

// For Memcached driver
$memcached = new \Memcached;
$memcached->addServer('localhost', 11211) or die ("Could not connect");
$SimpleCache = new \Rundiz\SimpleCache\Drivers\Memcached($memcached);
unset($memcached);

// For APC (deprecated, use APCu instead).
$SimpleCache = new \Rundiz\SimpleCache\Drivers\Apc();

// For APCu
$SimpleCache = new \Rundiz\SimpleCache\Drivers\Apcu();

// For File system (very basic cache driver)
$SimpleCache = new \Rundiz\SimpleCache\Drivers\FileSystem();

// For memory cache (This is using PHP array, if class was unset everything will be removed)
$SimpleCache = new \Rundiz\SimpleCache\Drivers\Memory();
```

Common methods to get, set, delete, or anything else please read more at [PSR-16 document](https://www.php-fig.org/psr/psr-16/).
Examples.

```
// To get or fetch cache data.
$SimpleCache->get('cache_key');

// To get multiple cache data.
$SimpleCache->getMultiple(['cache_key1', 'cache_key2']);

// To check cache exists.
$SimpleCache->has('cache_key');

// To save cache data.
$SimpleCache->set('cache_key', 'cache data. (any type of data... string, integer, double, array, object, etc.)', 90);

// To save multiple cache data.
$SimpleCache->setMultiple([
    'cache_key1' => 'string value',
    'cache_key2' => 12345,
], 90);

// To delete cache.
$SimpleCache->delete('cache_key');

// To delete multiple cache.
$SimpleCache->deleteMultiple(['cache_key1', 'cache_key2']);

// To clear all cached.
$SimpleCache->clear();
```

### Fallback cache drivers

[](#fallback-cache-drivers)

You can set many cache drivers as fallback in case that some driver is not installed on the server.

```
if (class_exists('\\Memcached')) {
    $memcached = new \Memcached;
    $memcached->addServer('localhost', 11211) or die ("Could not connect");
    $SimpleCache = new \Rundiz\SimpleCache\Drivers\Memcached($memcached);
    unset($memcached);
} elseif (class_exists('\\Memcache')) {
    $memcache = new \Memcache;
    $memcache->connect('localhost', 11211) or die ("Could not connect");
    $SimpleCache = new \Rundiz\SimpleCache\Drivers\Memcached($memcache);
    unset($memcache);
} elseif (function_exists('apcu_fetch')) {
    $SimpleCache = new \Rundiz\SimpleCache\Drivers\Apcu();
} else {
    $SimpleCache = new \Rundiz\SimpleCache\Drivers\FileSystem();
}
```

### Namespace/Sub folders for file system cache

[](#namespacesub-folders-for-file-system-cache)

In file system cache, you can use namespace or sub folders by just add "." (dot) to the cache id.
For example: `$SimpleCache->set('Model.Accounts.id1', $userdata, 120);`.
This will save the cache file to **Model/Accounts/id1** folder.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance53

Moderate activity, may be stable

Popularity15

Limited adoption so far

Community8

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

Recently: every ~500 days

Total

6

Last Release

558d ago

Major Versions

v2.0 → 3.02019-06-21

PHP version history (3 changes)v2.0PHP &gt;=5.3.0

3.0PHP &gt;=7.0

3.1.0PHP &gt;=8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1568262?v=4)[vee w,](/maintainers/ve3)[@ve3](https://github.com/ve3)

---

Top Contributors

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

---

Tags

apcapcucachefilesystemmemcachememcachedcachememcachedapcuapcmemcachephp cachefile system cachefilesystem cache

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/rundiz-simple-cache/health.svg)](https://phpackages.com/packages/rundiz-simple-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.2M137](/packages/phpfastcache-phpfastcache)[sabre/cache

Simple cache abstraction layer implementing PSR-16

551.3M4](/packages/sabre-cache)[tedivm/stash

The place to keep your cache.

9614.9M126](/packages/tedivm-stash)[desarrolla2/cache

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

1342.5M48](/packages/desarrolla2-cache)[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.

114546.3k6](/packages/apix-cache)[robinn/phpcacheadmin

A web dashboard for your favorite caching system.

4463.6k1](/packages/robinn-phpcacheadmin)

PHPackages © 2026

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