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

ActiveLibrary[Caching](/categories/caching)

websoftwares/cache
==================

Yet another caching implementation

142PHP

Since Apr 6Pushed 13y agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Cache
=====

[](#cache)

Yet another caching implementation.

[![Build Status](https://camo.githubusercontent.com/87ed01b7d36182d9490790d360744a796f6ce968cdadf918f0bba3273c4150d0/68747470733a2f2f6170692e7472617669732d63692e6f72672f776562736f667477617265732f43616368652e706e67)](https://travis-ci.org/websoftwares/Cache)

Usage
-----

[](#usage)

Basic usage applies to all cache storage options

```
use Websoftwares\Cache, Websoftwares\Storage\File;

$cache = Cache::storage(new File());

$cache->save('key',["a","b","c"]);

// Retrieve the cache

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

Storage
-------

[](#storage)

Available storage options:

- Apc (saves the cache to apc)
- File (saves the cache to a file)
- Memcache (save the cache to a memcache instance)
- Memcached (save the cache to a memcached instance)
- MongoDB (save the cache to a mongo instance)
- Redis (save the cache to a redis instance)
- Riak (save the cache to a riak instance)

Apc
---

[](#apc)

```
use Websoftwares\Cache, Websoftwares\Storage\Apc;

$apc = Cache::storage(new Apc())
 ->setExpiration(86400);

$apc->save('key',["a","b","c"]);

// Retrieve the cache

$apc->get('key');
```

File
----

[](#file)

```
use Websoftwares\Cache, Websoftwares\Storage\File;

$cache = Cache::storage(new File())
 ->setPath('/super/spot')
 ->setExpiration(86400);

$cache->save('key',["a","b","c"]);

// Retrieve the cache

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

Memcache
--------

[](#memcache)

This requires u have the PHP memcache extension installed.

on Debian/Ubuntu systems for example install like this (requires administrative password).

```
sudo apt-get install php5-memcache

```

```
use Websoftwares\Cache, Websoftwares\Storage\Memcache;

$memcache = Cache::storage(new Memcache())
    ->setConnection(function() {
        $instance = new \Memcache;
        $instance->connect('localhost','11211');
        return $instance;
    })
    ->setExpiration(86400);

$memcache->save('key',["a","b","c"]);

// Retrieve the cache

$memcache->get('key');
```

Memcached
---------

[](#memcached)

This requires u have the PHP memcached extension installed.

on Debian/Ubuntu systems for example install like this (requires administrative password).

```
sudo apt-get install php5-memcached

```

```
use Websoftwares\Cache, Websoftwares\Storage\Memcached;

$memcached = Cache::storage(new Memcached())
    ->setConnection(function() {
        $instance = new \Memcached();
        $instance->addServer("localhost", 11211);
        return $instance;
    })
    ->setExpiration(86400);

$memcached->save('key',["a","b","c"]);

// Retrieve the cache

$memcached->get('key');
```

Mongo
-----

[](#mongo)

This storage option makes use of the "ensureIndex" method option "expireAfterSeconds".

This option can only be used if the following requirements are met.

Requirements:

- Latest PHP Mongo extension installed
- mongoDB deamon version 2.2+ | [read more](http://docs.mongodb.org/manual/tutorial/expire-data/ "More information")

On debian/ubuntu systems run the following command to install the mongo extension (requires administrator password).

```
sudo pecl install mongo

```

```
use Websoftwares\Cache, Websoftwares\Storage\Mongo;

$mongo = Cache::storage(new Mongo())
    ->setConnection(function() {
        $m = new \MongoClient();
        $db = $m->mongocache;
        return $db;
    })
    ->setCollection('test')
    ->setExpiration(86400);

$mongo->save('key',["a","b","c"]);

// Retrieve the cache

$mongo->get('key');
```

Redis
-----

[](#redis)

This requires u have the PHP [Predis](https://github.com/nrk/predis "Predis") package installed.

```
use Websoftwares\Cache, Websoftwares\Storage\Redis;

$redis = Cache::storage(new Redis())
    ->setConnection(function() {
        $client = new \Predis\Client([
            'scheme'   => 'tcp',
            'host'     => '127.0.0.1',
            'port'     => 6379,
        ]);
        return $client;
    })
    ->setExpiration(86400);

$redis->save('key',["a","b","c"]);

// Retrieve the cache

$redis->get('key');
```

Riak
----

[](#riak)

This requires u have the PHP [Riak](https://github.com/basho/riak-php-client "Riak") official package installed.

```
use Websoftwares\Cache, Websoftwares\Storage\Riak;

$riak = Cache::storage(new Riak())
    ->setConnection(function() {
        $client = new \Basho\Riak\Riak('127.0.0.1', 8098);
        return $client;
    })
    ->setBucket('testBucket')
    ->setExpiration(86400);

$riak->save('key',["a","b","c"]);

// Retrieve the cache

$riak->get('key');
```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[barryvdh/laravel-httpcache

HttpCache for Laravel

502404.4k10](/packages/barryvdh-laravel-httpcache)

PHPackages © 2026

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