PHPackages                             webscale/webscale - 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. webscale/webscale

ActiveLibrary[Caching](/categories/caching)

webscale/webscale
=================

Cache abstraction library

07PHP

Since Mar 23Pushed 12y ago1 watchersCompare

[ Source](https://github.com/WebScalePHP/webscale)[ Packagist](https://packagist.org/packages/webscale/webscale)[ RSS](/packages/webscale-webscale/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

WebScale
========

[](#webscale)

WebScale is a cache abstraction library **under development**. It is based on proposed [PSR-6](https://github.com/Crell/fig-standards/blob/Cache/proposed/cache.md) interfaces. First stable release (1.0) is expected to be ready soon after PSR-6 is finalised.

WebScale has currently drivers for following data stores:

- Apc(u)
- XCache
- WinCache
- Redis
- Memcache(d)
- Couchbase
- File system
- PHP memory

How can I contribute?
---------------------

[](#how-can-i-contribute)

- Fork, hack, commit and push. Do **not** put your name to source code files (@author tags).
- Share your (non-PSR-6) ideas on the issues tab.
- Go [here](https://groups.google.com/forum/?fromgroups#!forum/php-fig) and push PSR-6 forward.

Usage
-----

[](#usage)

### Set up your pools

[](#set-up-your-pools)

```
$driver = new WebScale\Driver\Apc;

// items in different pools are separated from each other
$userpool = new WebScale\Pool($driver, 'users');
$blogpostpool = new WebScale\Pool($driver, 'blogposts');
```

### Get and set items

[](#get-and-set-items)

```
$item = $pool->getItem('foo');
if ($item->isHit()) {
    /*
        Item::get() does not make a second call to your
        cache backend: value is already there.
    */
    $value = $item->get();
} else {
    $value = doSomeExpensiveStuff();
    $item->set($value, 3600);
}
// now do something with the value
```

### Delete items

[](#delete-items)

```
/*
    Don't worry: item's value isn't actually fetched
    unless you call Item::isHit or Item::get before
    deleting it.
 */
$pool->getItem('foo')->delete();

/*
    Invalidate all items from a pool.
 */
$pool->clear();
```

### Logging

[](#logging)

You can use any PSR-3 compatible logger.

```
$driver = WebScale\Driver\Factory::getRedisDriver(array(
    'host' => 'localhost',
    'port' => 6379
));

$logger = new Monolog\Logger('log', array(
    /* handlers */
));

$driver->setLogger($logger);
```

### Session handler

[](#session-handler)

```
$driver = WebScale\Driver\Factory::getMemcachedDriver(array(
    'host' => 'localhost',
    'port' => 11211
));

$handler = new WebScale\Session\Handler($driver);
$handler->register();

session_start();
```

Cache another Session handler. This allows you to store sessions in a long-term storage (like database) while still keeping currently active sessions in the cache.

```
$driver = WebScale\Driver\Factory::getMemcachedDriver(array(
    'host' => 'localhost',
    'port' => 11211
));

$pdoHandler = new Acme\PdoSessionHandler($pdo);

$handler = new WebScale\Session\DecoratingHandler($driver, $pdoHandler);
$handler->register();

session_start();
```

### Nested pools

[](#nested-pools)

Pool can also have nested subpools. Clearing subpool does not affect it's parent or siblings. This functionality is not part of the current PSR-6 draft.

```
$mainpool = new WebScale\Pool($driver, 'example.com');
$postpool = $mainpool->getSubPool('posts');
$userpool = $mainpool->getSubPool('users');

// Invalidate items from the userpool.
$userpool->clear();

// Invalidate all items from the main pool and it's subpools.
$mainpool->clear();
```

### Piping multiple operations at once

[](#piping-multiple-operations-at-once)

This functionality should be considered experimental. It is (obviously) faked with some drivers. Not part of the current PSR-6 draft.

```
$collection = $pool->getItems(array('foo', 'bar', 'baz'));

$output = $collection->pipe(function ($collection) use ($db) {
    foreach ($collection as $key => $item) {
        if (!$item->isHit()) {
            $value = $db->xyz->findOne(array('key' => $key));
            $item->set($value);
        }
    }
});

print_r($output);
/*
    Array
    (
        [foo] => value
        [bar] => value
        [baz] => value
    )
*/
```

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

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://avatars.githubusercontent.com/u/1369192?v=4)[sgtk](/maintainers/sgtk)[@SgtK](https://github.com/SgtK)

### Embed Badge

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

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

###  Alternatives

[iazaran/smart-cache

Smart Cache is a caching optimization package designed to enhance the way your Laravel application handles data caching. It intelligently manages large data sets by compressing, chunking, or applying other optimization strategies to keep your application performant and efficient.

21114.2k](/packages/iazaran-smart-cache)[phpfastcache/phpssdb

PHP SSDB Driver for phpFastCache

14736.9k1](/packages/phpfastcache-phpssdb)

PHPackages © 2026

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