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

ActiveLibrary[Caching](/categories/caching)

moust/silex-cache
=================

Cache service provider for Silex application

v2.0.2(8y ago)33138.4k↓35.1%191MITPHPPHP &gt;=5.3.3

Since Mar 24Pushed 8y ago5 watchersCompare

[ Source](https://github.com/moust/silex-cache-service-provider)[ Packagist](https://packagist.org/packages/moust/silex-cache)[ RSS](/packages/moust-silex-cache/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (5)Used By (1)

[![Build Status](https://camo.githubusercontent.com/143e3f773b704ecd1bb08cf5822b1083e7a11abc53291215336d2bab2a4b68b5/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f6d6f7573742f73696c65782d63616368652d736572766963652d70726f76696465722e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/moust/silex-cache-service-provider)

Silex Cache Service Provider
============================

[](#silex-cache-service-provider)

The Silex Cache service provider allows you to use several PHP opcode cache in your Silex application.

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

[](#installation)

To enable it, add this dependency to your `composer.json` file:

```
{
    "require": {
        "moust/silex-cache": "~2.0"
    }
}
```

Parameters
----------

[](#parameters)

- **cache.options**: Array of cache options.
    - **driver**: The cache driver to use. Can be any of: `apc`,`apcu`, `array`, `file`, `memcache`, `memcached`, `xcache`, `redis`, `wincache`.
    - **cache\_dir**: Only relevant for `file` cache driver, specifies the path to the cache directory
    - **memcache**: Only relevant for `memcache` cache driver, provide the Memcache instance to use. If not defined, a default Memcache object will be instanciated. See the Memcache documentation for additional informations : [PHP: Memcache - Manual](http://www.php.net/manual/en/book.memcache.php)
    - **memcached**: Only relevant for `memcached` cache driver, provide the Memcached instance to use. If not defined, a default Memcached object will be instanciated. See the Memcached documentation for additional informations : [PHP: Memcached - Manual](http://www.php.net/manual/en/book.memcached.php)
    - **redis**: Only relevant for `redis` cache driver, provide the Redis instance to use. If not defined, a default Redis object will be instanciated. See the PhpRedis documentation for additional informations : [PhpRedis](https://github.com/nicolasff/phpredis/)

Registering
-----------

[](#registering)

```
$app->register(new Moust\Silex\Provider\CacheServiceProvider(), array(
    'cache.options' => array(
        'driver' => 'apc'
    )
));
```

Usage
-----

[](#usage)

The Cache provider provides a cache service. Here is a usage example:

```
// stores a variable
$app['cache']->store('foo', 'bar');
// stores a variable with a 1 minute lifetime
$app['cache']->store('foo', 'bar', 60);
// fetch variable
echo $app['cache']->fetch('foo');
// delete variable
$app['cache']->delete('foo');
// clear all cached variables
$app['cache']->clear();
```

Using multiple caches
---------------------

[](#using-multiple-caches)

The Cache provider can allow access to multiple caches. In order to configure the cache drivers, replace the `cache.options` with `caches.options`. `caches.options` is an array of configurations where keys are cache names and values are options:

```
$app->register(new Moust\Silex\Provider\CacheServiceProvider(), array(
    'caches.options' => array(
        'apc' => array(
            'driver' => 'apc'
        ),
        'filesystem' => array(
            'driver' => 'file',
            'cache_dir' => './temp'
        ),
        'memory' => array(
            'driver' => 'array'
        ),
        'memcache' => array(
            'driver' => 'memcache',
            'memcache' => function () {
                $memcache = new \Memcache;
                $memcache->connect('localhost', 11211);
                return $memcache;
            }
        )
    )
));
```

The first registered cache is the default and can simply be accessed as you would if there was only one. Given the above configuration, these two lines are equivalent:

```
$app['cache']->store('foo', 'bar');

$app['caches']['apc']->store('foo', 'bar');
```

Licence
=======

[](#licence)

Copyright (c) 2014 Quentin Aupetit

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity44

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 84.6% 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 ~190 days

Total

4

Last Release

3135d ago

Major Versions

v1.0 → v2.02016-07-07

### Community

Maintainers

![](https://www.gravatar.com/avatar/202c6d884af8eb645c5a3d4141b84c1ce1c450263f3694d4ef6cc1d384e2b024?d=identicon)[moust](/maintainers/moust)

---

Top Contributors

[![moust](https://avatars.githubusercontent.com/u/1053102?v=4)](https://github.com/moust "moust (55 commits)")[![declic3000](https://avatars.githubusercontent.com/u/14113316?v=4)](https://github.com/declic3000 "declic3000 (6 commits)")[![adam187](https://avatars.githubusercontent.com/u/156628?v=4)](https://github.com/adam187 "adam187 (1 commits)")[![benscholler](https://avatars.githubusercontent.com/u/431530?v=4)](https://github.com/benscholler "benscholler (1 commits)")[![kevinboudot](https://avatars.githubusercontent.com/u/1036069?v=4)](https://github.com/kevinboudot "kevinboudot (1 commits)")[![kisscool-fr](https://avatars.githubusercontent.com/u/797858?v=4)](https://github.com/kisscool-fr "kisscool-fr (1 commits)")

---

Tags

librarycacheserviceprovidersilex

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[chh/cache-service-provider

Provides easy to use caching for Silex applications, built on top of the doctrine/cache package

23163.0k1](/packages/chh-cache-service-provider)[rapidwebltd/rw-file-cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

15191.3k7](/packages/rapidwebltd-rw-file-cache)

PHPackages © 2026

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