PHPackages                             kuikui/memcache-service-provider - 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. kuikui/memcache-service-provider

ActiveLibrary[Caching](/categories/caching)

kuikui/memcache-service-provider
================================

Memcache integration for Silex.

v2.0.0(11y ago)1231.6k↓33.3%8[1 PRs](https://github.com/KuiKui/MemcacheServiceProvider/pulls)MITPHP

Since Aug 22Pushed 11y ago3 watchersCompare

[ Source](https://github.com/KuiKui/MemcacheServiceProvider)[ Packagist](https://packagist.org/packages/kuikui/memcache-service-provider)[ Docs](https://github.com/KuiKui/MemcacheServiceProvider)[ RSS](/packages/kuikui-memcache-service-provider/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (5)Used By (0)

Memcache service provider for Silex 2.x
=======================================

[](#memcache-service-provider-for-silex-2x)

[![Build Status](https://camo.githubusercontent.com/eaa920e36d334319aa7fc57eac79bbbaabaf63442139d94dd9e6c50f79d238b3/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f4b75694b75692f4d656d63616368655365727669636550726f76696465722e7376673f6272616e63683d6d6173746572)](http://travis-ci.org/KuiKui/MemcacheServiceProvider?branch=master)[![Total Downloads](https://camo.githubusercontent.com/d9018e1e1a4e1fc376e5199dc35d59cb49b5c20d017465e79a9fcc9781e1960b/68747470733a2f2f706f7365722e707567782e6f72672f6b75696b75692f6d656d63616368652d736572766963652d70726f76696465722f646f776e6c6f6164732e737667)](https://packagist.org/packages/kuikui/memcache-service-provider)

It provides access to :

- a simple Memcache wrapper with very simple API for standard use,
- or your own Memcache wrapper with `$app` injection for custom use,
- or a genuine Memcache(d) object for advanced use.

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

[](#installation)

Create a composer.json in your projects root-directory :

```
{
    "require": {
        "kuikui/memcache-service-provider": "~2.0"
    }
}
```

and run :

```
$ curl -sS http://getcomposer.org/installer | php
$ php composer.phar install
```

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

[](#registering)

```
$app->register(new KuiKui\MemcacheServiceProvider\ServiceProvider());
```

Example
-------

[](#example)

```
$app->register(new KuiKui\MemcacheServiceProvider\ServiceProvider());

// Simple use
$app['memcache']->set('key', 'value');
$value = $app['memcache']->get('key');
$app['memcache']->delete('key');

// Advanced use : use \Closure to generate default value and save it during a retrieve process
$value = $app['memcache']->get('key', function() use ($app) {
    return $app['some_other_service']->getData();
});
```

Options
-------

[](#options)

After registration, you can customize the service with these options :

#### Connections

[](#connections)

Allows you to set up one or more Memcache connections.
Each connection should be defined as follows `array('ip_address', port)`.

```
$app['memcache.connections'] = array(
    array('127.0.0.1', 11211),
    array('10.0.1.118', 12345)
; // default: array('127.0.0.1', 11211)
```

#### Class

[](#class)

Allows you to choose between the two PHP Memcache libraries : `\Memcache` or `\Memcached`.

```
$app['memcache.class'] = '\Memcached'; // default: '\Memcache'
```

#### Wrapper

[](#wrapper)

- By default, you access to an instance of `KuiKui\MemcacheServiceProvider\SimpleWrapper`.
- For custom needs, you can use your own wrapper :

```
$app['memcache.wrapper'] = '\My\Custom\Wrapper';
```

- Or you can have direct acces to Memcache(d) object :

```
$app['memcache.wrapper'] = false;
```

#### Duration

[](#duration)

If you use `SimpleWrapper`, you can configure the default duration of cached data (in seconds):

```
$app['memcache.default_duration'] = 60; // default: 0 (no limit)
```

Running the tests
-----------------

[](#running-the-tests)

The development environment is provided by Vagrant and the [Xotelia box](https://github.com/Xotelia/VagrantBox).

```
$ cp Vagrantfile.dist Vagrantfile
$ vagrant up
$ vagrant ssh
```

```
$ cd /vagrant
$ composer install
$ ./vendor/bin/atoum
```

Dependencies
------------

[](#dependencies)

PHP 5.5+

MemcacheServiceProvider needs one of these PHP modules to be installed :

- [memcache](http://www.php.net/manual/en/book.memcache.php)
- [memcached](http://www.php.net/manual/en/book.memcached.php)

Credits
-------

[](#credits)

Deeply inspired by [MemcacheServiceProvider](https://github.com/RafalFilipek/MemcacheServiceProvider) from Rafał Filipek.
Tested with [atoum](http://atoum.org).

License
-------

[](#license)

The MemcacheServiceProvider is licensed under the [MIT license](https://github.com/KuiKui/MemcacheServiceProvider/blob/master/LICENSE).

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 74.2% 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 ~89 days

Total

4

Last Release

4021d ago

Major Versions

1.x-dev → v2.0.02015-05-16

### Community

Maintainers

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

---

Top Contributors

[![KuiKui](https://avatars.githubusercontent.com/u/748924?v=4)](https://github.com/KuiKui "KuiKui (23 commits)")[![damien-qc](https://avatars.githubusercontent.com/u/12374806?v=4)](https://github.com/damien-qc "damien-qc (4 commits)")[![makusu](https://avatars.githubusercontent.com/u/953584?v=4)](https://github.com/makusu "makusu (2 commits)")[![soebbing](https://avatars.githubusercontent.com/u/174161?v=4)](https://github.com/soebbing "soebbing (2 commits)")

---

Tags

silexmemcache

### Embed Badge

![Health badge](/badges/kuikui-memcache-service-provider/health.svg)

```
[![Health](https://phpackages.com/badges/kuikui-memcache-service-provider/health.svg)](https://phpackages.com/packages/kuikui-memcache-service-provider)
```

###  Alternatives

[sabre/cache

Simple cache abstraction layer implementing PSR-16

541.2M3](/packages/sabre-cache)[predis/service-provider

Predis service provider for the Silex microframework

68546.6k1](/packages/predis-service-provider)[robinn/phpcacheadmin

A web dashboard for your favorite caching system.

4441.1k1](/packages/robinn-phpcacheadmin)[moust/silex-cache

Cache service provider for Silex application

33138.4k1](/packages/moust-silex-cache)[beryllium/cachebundle

Provides an interface to Memcache for Symfony2 applications

32135.8k](/packages/beryllium-cachebundle)[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)

PHPackages © 2026

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