PHPackages                             clickalicious/memcached.php - 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. clickalicious/memcached.php

ActiveLibrary[Caching](/categories/caching)

clickalicious/memcached.php
===========================

Memcached.php - Plain vanilla PHP Memcached client with full support of Memcached protocol.

v1.0.1(10y ago)2973.7k↓19%11[3 issues](https://github.com/clickalicious/memcached-php/issues)[1 PRs](https://github.com/clickalicious/memcached-php/pulls)5BSD-3-ClausePHPPHP &gt;=5.4.0

Since Jan 10Pushed 9y ago3 watchersCompare

[ Source](https://github.com/clickalicious/memcached-php)[ Packagist](https://packagist.org/packages/clickalicious/memcached.php)[ Docs](https://github.com/clickalicious/Memcached.php)[ RSS](/packages/clickalicious-memcachedphp/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (3)Versions (10)Used By (5)

[![](https://avatars0.githubusercontent.com/u/26927954?v=3&s=140)](https://avatars0.githubusercontent.com/u/26927954?v=3&s=140)

---

[![Logo of Memcached.php](docs/logo-large.png)](docs/logo-large.png)

Plain vanilla PHP `Memcached` client library with full support of Memcached ASCII protocol

[![Build Status](https://camo.githubusercontent.com/0c80e73cb6635ee306f279f5ead2de24e1c12950341e8463efc8a21019283836/68747470733a2f2f7472617669732d63692e6f72672f636c69636b616c6963696f75732f4d656d6361636865642e7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/clickalicious/Memcached.php)[![Scrutinizer](https://camo.githubusercontent.com/5f8c31e0dd1e29023427ae575b9018ff468d7e00a80f4e49a9e3cbeecb92d471/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f636c69636b616c6963696f75732f4d656d6361636865642e7068702e737667)](https://scrutinizer-ci.com/g/clickalicious/Memcached.php/)[![Scrutinizer Coverage](https://camo.githubusercontent.com/476a770eb483597031e7f11df88155b56ad7588ea588628fc89eeac357d40bce/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f636c69636b616c6963696f75732f4d656d6361636865642e7068702e7376673f6d61784167653d32353932303030)](http://clickalicious.github.io/Memcached.php/)[![clickalicious open-source](https://camo.githubusercontent.com/c244587ebb73cb5386d137729f3bb3348c448eef1782b945b6d03f4f5b5361c2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636c69636b616c6963696f75732d6f70656e2d2d736f757263652d677265656e2e7376673f7374796c653d666c6174)](https://www.clickalicious.de/)[![GitHub release](https://camo.githubusercontent.com/fb0fec37315cc8e1bdd36051991c8cc4662b1b4bf8c320112626b0848de132ed/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f636c69636b616c6963696f75732f4d656d6361636865642e7068702e7376673f7374796c653d666c6174)](https://github.com/clickalicious/Memcached.php/releases)[![Waffle.io](https://camo.githubusercontent.com/65050fc176bb6d403b3d2599210d0b7c4dbae8a608b289c08f315b80e642b4cc/68747470733a2f2f696d672e736869656c64732e696f2f776166666c652f6c6162656c2f636c69636b616c6963696f75732f4d656d6361636865642e7068702f696e25323070726f67726573732e737667)](https://waffle.io/clickalicious/Memcached.php)[![SensioLabsInsight](https://camo.githubusercontent.com/0f083d8dc62fbaf766ba19a0ccd19dd8c5592905e9c15f1e3c688d72d9a74e38/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f35376566613739632d356563652d343239362d616261622d3563336562393035336332632f6d696e692e706e67)](https://insight.sensiolabs.com/projects/57efa79c-5ece-4296-abab-5c3eb9053c2c)[![Packagist](https://camo.githubusercontent.com/5cf797a4ae60a0e517498f7314df1272c7ad81cede96392f9a865ad57bfdf2fc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f636c69636b616c6963696f75732f6d656d6361636865642e7068702e7376673f7374796c653d666c6174)](http://opensource.org/licenses/BSD-3-Clause)Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Example](#example)
- [Requirements](#requirements)
- [Philosophy](#philosophy)
- [Versioning](#versioning)
- [Roadmap](#roadmap)
- [Security-Issues](#security-issues)
- [License »](LICENSE)

Features
--------

[](#features)

- ~ 100% of `Memcached` *ASCII*-protocol specification covered
- Support for storing native PHP variable types (arrays, objects ...)
- Increment &amp; Decrement support
- Efficient connection sharing
- Configurable connection close behavior
- Clean &amp; well documented code
- Unit-Tested

**Memcached.php** covers almost 100% of the `Memcached` protocol specification. The code is clean, full documented and developed following the PSR coding standards (PSR-0/4, PSR-1, PSR-2). The code is unit-tested (PHPUnit) and the coverage is high. The library supports &lt;incr&gt; and &lt;decr&gt; command on stored integers (strings) and the [connection handling is done like recommended](https://github.com/memcached/memcached/blob/master/doc/protocol.txt#L10 "Keep connections open and share them via a pool across instances.") in the `Memcached` protocol specification. Last but not least it supports seven of [PHP's eight variable types](http://php.net/manual/en/language.types.intro.php "PHP's variable types") - in detail four scalar types:

```
boolean
integer
float (floating-point number [double])
string

```

two compound types:

```
array
object

```

and finally one special type:

```
NULL

```

So `resource` is the only type not supported.

Example
-------

[](#example)

- Create a `client` instance and connect it (*lazy*) to `Memcached` daemon on host *127.0.0.1* (on default port \[11211\])
- Set *key* **foo** with *value* **1.00**
- Retrieve *value* for *key* **foo**

```
$client = new \Clickalicious\Memcached\Client('127.0.0.1');

// Set a value of type float
$client->set('foo', 1.00);

// Returns 1.00 as PHP's type float!
$client->get('foo');
```

You will find a demonstration `Demo.php` showing in detail how to use the **Memcached.php** `client`.

Requirements
------------

[](#requirements)

- `PHP >= 5.4` (compatible up to version 5.6 as well as 7.x - but **not compatible** with HHVM)

Philosophy
----------

[](#philosophy)

This client is neither tested nor designed to be used in heavy load environments. It was designed and developed by me as a client library for my [phpMemAdmin](https://github.com/clickalicious/phpMemAdmin "phpMemAdmin on github") project. So I was able to remove dependencies of both `Memcache` + `Memcached` (PECL) extensions - both are designed in a way i don't like. I've tried to align 100% with the Memcached protocol specification. In some cases I didn't liked the naming convention and so I created some proxies. As an example - I decided to implement increment() as proxy to incr() and decrement() as proxy to decr(). I will add some more responsibilities in some more classes like a [PSR compatible](https://github.com/php-fig/fig-standards/blob/master/proposed/cache.md "PSR Cache proposal") Caching proxy and a Pool/Cluster Class for management operations soon.

Versioning
----------

[](#versioning)

For a consistent versioning i decided to make use of `Semantic Versioning 2.0.0` . Its easy to understand, very common and known from many other software projects.

Roadmap
-------

[](#roadmap)

- Target stable release `1.0.0`
- `>= 90%` test coverage
- Security check through 3rd-Party (Please get in contact with me)

[![Throughput Graph](https://camo.githubusercontent.com/18dba228b03954b0091c2e22d3b3b1ba5cac4608744fb1035d2c024dd971f539/68747470733a2f2f6772617068732e776166666c652e696f2f636c69636b616c6963696f75732f4d656d6361636865642e7068702f7468726f7567687075742e737667)](https://waffle.io/clickalicious/Memcached.php/metrics)

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

[](#installation)

The recommended way to install this library is through [Composer](http://getcomposer.org/). Require the `clickalicious/memcached.php` package into your `composer.json` file:

```
{
    "require": {
        "clickalicious/memcached.php": "~0.1"
    }
}
```

**Memcached.php** is also available as [download from github packed as zip-file](https://github.com/clickalicious/Memcached.php/archive/master.zip "zip package containing library for download") or via `git clone https://github.com/clickalicious/Memcached.php.git .`

Data
----

[](#data)

`Strings`, `Integers` and `Float-Values` are never modified by this library in any way. Those types will be stored by `Memcached`'s internal system - while all other types will be serialized by this client and can optionally be stored compressed (*LZW*/*Smaz*) - in one of the next releases of this library - targeting 0.4.0. I'm working on an PoC implementation of `Smaz - a short string compression library` () and on a german translation of the translation table used by `Smaz`.

Metadata
--------

[](#metadata)

`Memcached` provides a 32 Bit (Version &gt; 1.2.1) unsigned Integer field for meta data. From the `Memcached` protocol specification:

> Note that in memcached 1.2.1 and higher, flags may be 32-bits, instead of 16, but you might want to restrict yourself to 16 bits for compatibility with older versions.

**Memcached.php** uses this field for its meta data. The meta data is required to mark data for serialization and stuff like this. This meta data is stored via the clients` flags field. The lower first **8 Bits** (*lowest Byte*) are reserved by **Memcached.php**. The other 8 Bits (half of the 16 Bits) can be used by your app.

Documentation
-------------

[](#documentation)

The best and currently only existing documentation is the inline documentation of this project. So please have a look at the source to understand how **Memcached.php** works internally.

Tests
-----

[](#tests)

**Memcached.php** is unit-tested and the code coverage is high. For an in-detail view have a look at this always up to date [Code Coverage report](http://clickalicious.github.io/Memcached.php/dashboard.html "Code Coverage").

Running the Tests
You will find a PHPUnit configuration including testsuites in directory `tests/`. To run those configuration execute the following command on `cli`:

```
phpunit -c tests/phpunit.xml --testdox
```

### Tests

[](#tests-1)

The unit-tests are fired against an existing and real `Memcached` daemon. Please be aware that you need a running `Memcached` deamon on the host you run the unit-tests listening on the default port (11211). In Result the unit-tests are not that isolated cause they are bound to a running `Memcached` daemon and network as well.

Versioning
----------

[](#versioning-1)

For a consistent versioning i decided to make use of `Semantic Versioning 2.0.0` . Its easy to understand, very common and known from many other software projects.

Roadmap
-------

[](#roadmap-1)

- Hardening code - more stability!
- `\Clickalicious\Memcached\Proxy`
    This should become a proxy implementation which is able to act as `Memcache` or `Memcached` (both PECL) extension (emulate) for testing (primary mocking/stubbing).
- `\Clickalicious\Memcached\Server`
    This should become a virtual (emulated) mode which emulates a complete `Memcached` backend.
- Add compression support to be able to manipulate PECL Memcached stored data (FastLZ, zlib, LZW)
- Replace explodes and array operations for data anlysis with regular expressions.
- Increase coverage and cover (currently unused compression classes) more parts.

If you are interested in any of these features too - please let me know. Maybe we can adjust the priority and speed things up ...

Participate &amp; share
-----------------------

[](#participate--share)

... yeah. If you're a code monkey too - maybe we can build a force ;) If you would like to participate in either **Code**, **Comments**, **Documentation**, **Wiki**, **Bug-Reports**, **Unit-Tests**, **Bug-Fixes**, **Feedback** and/or **Critic** then please let me know as well! [![](https://camo.githubusercontent.com/2ae8719c2efbe82ef2938210c2dc507fffdfa7a73a1d982a01e5b27f7269af52/687474703a2f2f6a70696c6c6f72612e636f6d2f6769746875622d747769747465722d627574746f6e2f696d672f74776565742e706e67)](https://twitter.com/intent/tweet?hashtags=&original_referer=http%3A%2F%2Fgithub.com%2F&text=%23Memcached.php%20-%20Plain%20vanilla%20PHP%20%40Memcached%20client%20https%3A%2F%2Fgithub.com%2Fclickalicious%2FMemcached.php&tw_p=tweetbutton)

Sponsors
--------

[](#sponsors)

Thanks to our sponsors and supporters:

JetBrainsNavicat[![](https://camo.githubusercontent.com/b0914f08f6b588c7178490d5faf4b159b5c9dd3378288c92812c76aff1936790/68747470733a2f2f7265736f75726365732e6a6574627261696e732e636f6d2f6173736574732f6d656469612f6f70656e2d67726170682f6a6574627261696e735f323530783235302e706e67)](https://www.jetbrains.com/phpstorm/ "PHP IDE :: JetBrains PhpStorm")[![](https://camo.githubusercontent.com/05c63082503800035599f1c0cfc7bf20806173061e03634107592d18d096e648/687474703a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f656e2f392f39302f5072656d69756d536f66745f4e6176696361745f5072656d69756d5f4c6f676f2e706e67)](http://www.navicat.com/ "Navicat GUI - DB GUI-Admin-Tool for MySQL, MariaDB, SQL Server, SQLite, Oracle & PostgreSQL")###### Copyright

[](#copyright)

Icons made by [Freepik](http://www.freepik.com "Freepik") licensed by [CC 3.0 BY](http://creativecommons.org/licenses/by/3.0/ "Creative Commons BY 3.0")

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity42

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 50% 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 ~66 days

Recently: every ~111 days

Total

8

Last Release

3685d ago

Major Versions

v0.4.0 → v1.0.02016-04-11

### Community

Maintainers

![](https://www.gravatar.com/avatar/41051d0345550be4293d3cdb46cf4eadce771501ed813d3f736e648027f76c0e?d=identicon)[clickalicious](/maintainers/clickalicious)

---

Top Contributors

[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (2 commits)")[![aaarkadev](https://avatars.githubusercontent.com/u/974742?v=4)](https://github.com/aaarkadev "aaarkadev (1 commits)")[![bitdeli-chef](https://avatars.githubusercontent.com/u/3092978?v=4)](https://github.com/bitdeli-chef "bitdeli-chef (1 commits)")

---

Tags

asciiclientlibrarymemcachedphpplain-vanilla-phpphpclientmemorynosqlmemcachedmemcacheinmemory

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/clickalicious-memcachedphp/health.svg)

```
[![Health](https://phpackages.com/badges/clickalicious-memcachedphp/health.svg)](https://phpackages.com/packages/clickalicious-memcachedphp)
```

###  Alternatives

[clickalicious/phpmemadmin

phpMemAdmin - Bringing Memcached to the web

5076.0k](/packages/clickalicious-phpmemadmin)[alekseykorzun/memcached-wrapper-php

Optimized PHP 5 wrapper for Memcached extension that supports dog-piling, igbinary and local storage

2984.6k1](/packages/alekseykorzun-memcached-wrapper-php)[sabre/cache

Simple cache abstraction layer implementing PSR-16

541.2M3](/packages/sabre-cache)[robinn/phpcacheadmin

A web dashboard for your favorite caching system.

4441.1k1](/packages/robinn-phpcacheadmin)[avantarm/memcached-emulator

Memcached PHP extension emulator for Windows environments.

101.3k](/packages/avantarm-memcached-emulator)

PHPackages © 2026

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