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

ActiveLibrary

gadelkareem/silex-cache
=======================

Cache service provider for Silex application

1427PHP

Since Jul 18Pushed 9y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

[![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": {
        "gadelkareem/silex-cache": "1.0.*@dev"
    }
}
```

Parameters
----------

[](#parameters)

- **cache.options**: Array of cache options.
    - **driver**: The cache driver to use. Can be any of: `apc`, `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

23

—

LowBetter than 30% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 86.7% 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/5aa2214752b82c77feaed2fad417d2ab191b7bf788b2f2e3afd12d2bb916912a?d=identicon)[gadelkareem](/maintainers/gadelkareem)

---

Top Contributors

[![moust](https://avatars.githubusercontent.com/u/1053102?v=4)](https://github.com/moust "moust (39 commits)")[![gadelkareem](https://avatars.githubusercontent.com/u/1441127?v=4)](https://github.com/gadelkareem "gadelkareem (3 commits)")[![abellosovic](https://avatars.githubusercontent.com/u/5716167?v=4)](https://github.com/abellosovic "abellosovic (1 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)")

### Embed Badge

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

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

PHPackages © 2026

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