PHPackages                             kamisama/cakephp-memcached-engine - 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. kamisama/cakephp-memcached-engine

ActiveCakephp-plugin[Caching](/categories/caching)

kamisama/cakephp-memcached-engine
=================================

Memcached storage engine for CakePHP, using the memcached extension

0.12(12y ago)216289[1 issues](https://github.com/kamisama/CakePHP-Memcached-Engine/issues)[1 PRs](https://github.com/kamisama/CakePHP-Memcached-Engine/pulls)MITPHPPHP &gt;=5.3.0

Since Aug 26Pushed 11y ago1 watchersCompare

[ Source](https://github.com/kamisama/CakePHP-Memcached-Engine)[ Packagist](https://packagist.org/packages/kamisama/cakephp-memcached-engine)[ Docs](https://github.com/kamisama/CakePHP-Memcached-Engine)[ RSS](/packages/kamisama-cakephp-memcached-engine/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (1)Versions (9)Used By (0)

Memcached Cache engine for CakePHP [![Build Status](https://camo.githubusercontent.com/cc9cbd5a6a5f33c89c45b8dc7b123b93170545389379a9ea8c7a71f172cadad0/68747470733a2f2f7472617669732d63692e6f72672f6b616d6973616d612f43616b655048502d4d656d6361636865642d456e67696e652e706e67)](https://travis-ci.org/kamisama/CakePHP-Memcached-Engine) [![Coverage Status](https://camo.githubusercontent.com/93e1f1aa31207658e0095c3047fbfb5f7881996ff421555d1630aeff08c7e8c4/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6b616d6973616d612f43616b655048502d4d656d6361636865642d456e67696e652f62616467652e706e67)](https://coveralls.io/r/kamisama/CakePHP-Memcached-Engine) [![Latest Stable Version](https://camo.githubusercontent.com/05321b955dc79e76c0b507771b4a2e82a3538ce813b396c09c98112d8cdc861d/68747470733a2f2f706f7365722e707567782e6f72672f6b616d6973616d612f63616b657068702d6d656d6361636865642d656e67696e652f762f737461626c652e706e67)](https://packagist.org/packages/kamisama/cakephp-memcached-engine) [![Dependency Status](https://camo.githubusercontent.com/2d7c18b57528226dda5676914d303532881bcab15140dbd6bde51b766be1a436/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3532316265343962363332626163366135663030373562382f62616467652e706e67)](https://www.versioneye.com/user/projects/521be49b632bac6a5f0075b8)
=============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#memcached-cache-engine-for-cakephp----)

This is an alternative memcached cache engine to the memcache engine shipped by default with cakePhp. Default one uses the [memcache extension](http://ca.php.net/manual/en/book.memcache.php), whereas this one uses the [memcached extension](http://ca.php.net/manual/en/book.memcached.php). (notice the **d**)

Background
----------

[](#background)

### Benefits of Memcached over Memcache extension

[](#benefits-of-memcached-over-memcache-extension)

- Allow binary protocol
- Increment/Decrement a compressed key
- Uses igbinary for serialization (memcached has to be compiled with --enable-igbinary)

Igbinary is the big win of the memcached extension.

> Igbinary is a drop in replacement for the standard php serializer. Instead of time and space consuming textual representation, igbinary stores php data structures in a compact binary form. Savings are significant when using memcached or similar memory based storages for serialized data. You can expect about 50% reduction in storage requirement and speed is at least on par with the standard PHP serializer. Specific numbers depend on your data, of course.

see and [some benchmark](http://phpolyk.wordpress.com/2011/08/28/igbinary-the-new-php-serializer/)

For CakePHP 2.5+
----------------

[](#for-cakephp-25)

As of CakePHP 2.5, the memcached engine will be included in the core by default. No installation required.

For CakePHP 2.2, 2.3 and 2.4
----------------------------

[](#for-cakephp-22-23-and-24)

### Installation

[](#installation)

*\[Manual\]*

- Download this:
- Unzip that download.
- Copy the resulting folder to `app/Plugin`
- Rename the folder you just copied to `Memcached`

*\[GIT Submodule\]*

In your app directory type:

```
git submodule add -b master git://github.com/kamisama/CakePHP-Memcached-Engine.git Plugin/kamisama/Memcached
git submodule init
git submodule update

```

*\[GIT Clone\]*

In your `Plugin` directory type:

```
git clone -b master git://github.com/kamisama/CakePHP-Memcached-Engine.git Memcached

```

*\[Composer\]*

Add *kamisama/cakephp-memcached-engine* to your composer dependencies, then run

```
composer install

```

### Enable plugin

[](#enable-plugin)

You need to enable the plugin your `app/Config/bootstrap.php` file:

```
CakePlugin::load('Memcached');

```

If you are already using `CakePlugin::loadAll();`, then this is not necessary.

### Usage

[](#usage)

Add this line in the head of your core.php:

```
App::uses('MemcachedEngine', 'Memcached.Lib/Cache/Engine');

```

You can then use it in your cache configuration:

```
Cache::config('default', array('engine' => 'Memcached'));

```

For CakePHP 2.0 and 2.1
-----------------------

[](#for-cakephp-20-and-21)

### Installation

[](#installation-1)

Since defining cache engine in a plugin is not supported yet on these version, you have to :

- [Download](https://github.com/kamisama/CakePHP-Memcached-Engine/archive/master.zip) the plugin
- Copy the *MemcachedEngine.php* file located the `Lib/Cache/Engine` directory to the `Lib/Cache/Engine` directory (create it if needed) in your `app` folder.

### Enable plugin

[](#enable-plugin-1)

You need to enable the plugin your `app/Config/bootstrap.php` file:

```
CakePlugin::load('Memcached');

```

If you are already using `CakePlugin::loadAll();`, then this is not necessary.

```
Cache::config('default', array('engine' => 'Memcached'));

```

### Usage

[](#usage-1)

```
Cache::config('default', array('engine' => 'Memcached'));

```

Settings
--------

[](#settings)

The memcached cache engine can take the following options:

```
Cache::config('router', array(
    # Usual options
    'engine' => 'Memcached',
    'prefix' => 'mc_',
    'duration' => '+7 days', // Expires in 7 days, from now
    'servers' => array(
        '127.0.0.1', // Default port 11211
        '127.0.0.1:11212' // Or you can specify the port
    )

    # Memcached options
    'compress' => false,
    'persistent' => false,
    'login' => null,
    'password => null,
    'serialize' => 'php'
));

```

### compress

[](#compress)

*Default: `true`*
Compress the cached data. Unlike memcache, memcache**d** can increment/decrement compressed keys

### persistent

[](#persistent)

*Default: `false`*
Use a persistent connection to the memcached server. To enable, set `persistent` to an unique string, to identify the connection. All configurations using the same persistent value will share a single underlying connection.

### login and password

[](#login-and-password)

*Default: `null`*
The memcached server credidentials, if using SASL for authentication.

Memcached need to be compiled with SASL support, else it'll throw a `CacheException`.

### serialize

[](#serialize)

*Default: `php`*
The engine used to serialize the data.

Available serializer supported by memcached:

- php
- json
- igbinary

The memcached extension is by default compiled with the php serializer. To use the other serializer, the memcached extension must be compiled with the appropriate options. Refer to [Memcached](http://php.net/manual/en/book.memcached.php) documentation.

Using an invalid or not supported serializer engine will throw a `CacheException`.

igbinary is the recommended serializer.

Notes
-----

[](#notes)

Binary protocol is temporary disabled due to a Memcached [issue](https://github.com/php-memcached-dev/php-memcached/issues/21) with increment/decrement

Changelog
---------

[](#changelog)

\####Ver 0.12 (2013-10-06)

- Code optimization

\####Ver 0.11 (2013-09-19)

- Rename `serializer` setting to `serialize`
- Merge `persistent_id` setting with `persitent`, which now takes a string as argument

\####Ver 0.10 (2013-09-18)

- Add options to select the serializer engine

\####Ver 0.9 (2013-09-04)

- Fix copy/paste mistake preventing test to run

\####Ver 0.8 (2013-09-04)

- Minor code optimization
- Throw a CacheException when trying to use authentication with Memcached extension installed without SASL support

> **NOTE**: As of CakePHP 2.5, MemcachedEngine v0.8 will be included into the core.

\####Ver 0.7 (2013-08-26)

- Merge AmazonElastiCache support back into MemcachedEngine
- Coding standard fixes

\####Ver 0.6 (2013-08-26)

- Disable binary protocol due to a Memcached issue with increment/decrement [view issue](https://github.com/php-memcached-dev/php-memcached/issues/21)
- Add tests
- Add missing comma
- Add groups support
- Use `Memcached::getAllKeys()` to manage cache clearing

\####Ver 0.5 (2013-08-26)

- Pluginize cache engine (@josegonzalez)
- Add support for SASL authentication (@josegonzalez)

\####Ver 0.4 (2013-08-18)

- Fix #6: init() a second persistent connection returns false
- Add persistent\_id option to create separate persistent connection
- Skip duplicate when searching for key to clear

\####Ver 0.3 (2012-08-29)

- Code formatted to Cake standard

\####Ver 0.2 (2012-03-22)

- Implemented `Cache::clear()`

License
-------

[](#license)

This plugin is released under the MIT licence

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 87.5% 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 ~6 days

Total

8

Last Release

4649d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2935823cb9658334ccbba85d6a2be151d54ac52e1a6981b79b27a263e48320b1?d=identicon)[wa0x6e](/maintainers/wa0x6e)

---

Top Contributors

[![wa0x6e](https://avatars.githubusercontent.com/u/495709?v=4)](https://github.com/wa0x6e "wa0x6e (49 commits)")[![sogawa](https://avatars.githubusercontent.com/u/1695983?v=4)](https://github.com/sogawa "sogawa (4 commits)")[![josegonzalez](https://avatars.githubusercontent.com/u/65675?v=4)](https://github.com/josegonzalez "josegonzalez (3 commits)")

---

Tags

cakephpcachememcached

### Embed Badge

![Health badge](/badges/kamisama-cakephp-memcached-engine/health.svg)

```
[![Health](https://phpackages.com/badges/kamisama-cakephp-memcached-engine/health.svg)](https://phpackages.com/packages/kamisama-cakephp-memcached-engine)
```

###  Alternatives

[wp-media/wp-rocket

Performance optimization plugin for WordPress

7491.3M3](/packages/wp-media-wp-rocket)[tedivm/stash

The place to keep your cache.

9614.9M126](/packages/tedivm-stash)[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.3k10](/packages/helsingborg-stad-municipio)[tedivm/stash-bundle

Incorporates the Stash caching library into Symfony.

841.4M16](/packages/tedivm-stash-bundle)[sabre/cache

Simple cache abstraction layer implementing PSR-16

551.3M4](/packages/sabre-cache)[cache/memcached-adapter

A PSR-6 cache implementation using Memcached. This implementation supports tags

162.0M15](/packages/cache-memcached-adapter)

PHPackages © 2026

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