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 3d ago

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 10% 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://www.gravatar.com/avatar/8bdf9096a0d2c1cf6e3c8ad9c5c102cc1e6bdbf9e8fd722d413fe9214c980794?d=identicon)[sgtk](/maintainers/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

[predis/predis

A flexible and feature-complete Redis/Valkey client for PHP.

7.8k305.7M2.4k](/packages/predis-predis)[snc/redis-bundle

A Redis bundle for Symfony

1.0k39.4M67](/packages/snc-redis-bundle)[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[wp-media/wp-rocket

Performance optimization plugin for WordPress

7431.3M3](/packages/wp-media-wp-rocket)[illuminate/cache

The Illuminate Cache package.

12835.6M1.4k](/packages/illuminate-cache)[colinmollenhour/php-redis-session-abstract

A Redis-based session handler with optimistic locking

6325.6M14](/packages/colinmollenhour-php-redis-session-abstract)

PHPackages © 2026

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