PHPackages                             oihana/php-memcached - 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. [CLI &amp; Console](/categories/cli)
4. /
5. oihana/php-memcached

ActiveLibrary[CLI &amp; Console](/categories/cli)

oihana/php-memcached
====================

The Oihana PHP memcached library

1.0.3(9mo ago)037MPL-2.0PHPPHP &gt;=8.4

Since Aug 11Pushed 1mo agoCompare

[ Source](https://github.com/BcommeBois/oihana-php-memcached)[ Packagist](https://packagist.org/packages/oihana/php-memcached)[ Docs](https://github.com/BcommeBois/oihana-php-memcached)[ RSS](/packages/oihana-php-memcached/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (14)Versions (5)Used By (0)

Oihana PHP - memcached
======================

[](#oihana-php---memcached)

[![Oihana PHP System](https://raw.githubusercontent.com/BcommeBois/oihana-php-memcached/main/assets/images/oihana-php-memcached-logo-inline-512x160.png)](https://raw.githubusercontent.com/BcommeBois/oihana-php-memcached/main/assets/images/oihana-php-memcached-logo-inline-512x160.png)

This plugin provides CLI commands to control **Memcached** directly, using the PHP [Memcached extension](https://www.php.net/manual/en/book.memcached.php).

Built on top of the [Oihana PHP Commands](https://github.com/BcommeBois/oihana-php-commands/) Library.

[![Latest Version](https://camo.githubusercontent.com/14060e8ca4722446a258b6ddcf443853cae5d3828757dbf4bdcc758f696af9d6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f6968616e612f7068702d6d656d6361636865642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oihana/php-memcached)
[![Total Downloads](https://camo.githubusercontent.com/64677bc7397a85cbf42bf2a4ba4e2c15af87c61ace6676262c4db7b0b9d6449f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f6968616e612f7068702d6d656d6361636865642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oihana/php-memcached)
[![License](https://camo.githubusercontent.com/daabdfb743bf54cd8f14f407e4c7fdb0de8a2975ddb066d28467a6a14954bd43/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6f6968616e612f7068702d6d656d6361636865642e7376673f7374796c653d666c61742d737175617265)](LICENSE)

📦 Installation
--------------

[](#-installation)

> **Requires [PHP 8.4+](https://php.net/releases/)**

Install via [Composer](https://getcomposer.org):

```
composer require oihana/php-memcached
```

🚀 Quick Start
-------------

[](#-quick-start)

Memcached is an in-memory key–value store used to speed up dynamic web applications by caching data in RAM, reducing database load and latency. In PHP, you can use it through the [Memcached extension](https://www.php.net/manual/en/book.memcached.php).

Memcached is best for storing small, frequently accessed data like session data, API responses, or precomputed query results.

⚠️ It’s not persistent — data is lost if the server restarts.

### Initial setup

[](#initial-setup)

To run the memcached command locally, you need to create the configuration file `config/config.toml`.

You can do this by copying and editing the example config:

```
cp config/config.example.toml config/config.toml
```

### List Memcached info

[](#list-memcached-info)

Display basic Memcached information:

```
bin/console command:memcached
```

Example output:

```
Command:memcached
=================

localhost:11211
---------------

+--------------------+-------+
| Name               | Value |
+--------------------+-------+
| Current cache size | 0 MB  |
| Cache used         | 0 %   |
+--------------------+-------+

✅  Done in 5 ms
----------------

 Thank you and see you soon!
```

### List detailed Memcached info

[](#list-detailed-memcached-info)

Display full Memcached statistics:

```
bin/console command:memcached -v
```

Example output:

```
Command:memcached
=================

localhost:11211
---------------

+---------------------+-------+
| Name                | Value |
+---------------------+-------+
| Current cache size  | 0 MB  |
| Cache used          | 0 %   |
| Maximum cache size  | 64 MB |
| Total items         | 0     |
| Current connections | 2     |
| Total connections   | 10    |
| Get operations      | 0     |
| Set operations      | 0     |
+---------------------+-------+

✅  Done in 6 ms
----------------

 Thank you and see you soon!
```

### Flush Memcached cache

[](#flush-memcached-cache)

Clear the entire Memcached cache:

```
bin/console command:memcached --flush
```

Example output:

```
Command:memcached
=================

Flush the cache
---------------

 [OK] [✓] Flush operation succeeded

✅  Done in 4 ms
----------------
```

### Use composer

[](#use-composer)

You can run a composer script:

```
composer memcache
composer memcache -- -v
composer memcache -- --verbose

composer memcache -- -f
composer memcache -- --flush
```

✅ Running Unit Tests
--------------------

[](#-running-unit-tests)

To run all tests:

```
composer test
```

🧾 License
---------

[](#-license)

This project is licensed under the [Mozilla Public License 2.0 (MPL-2.0)](https://www.mozilla.org/en-US/MPL/2.0/).

👤 About the author
------------------

[](#-about-the-author)

- Author : Marc ALCARAZ (aka eKameleon)
- Mail :
- Website :

⚙️ Installing Memcached
-----------------------

[](#️-installing-memcached)

This section provides a step-by-step guide to installing and configuring Memcached.

### Linux (Debian)

[](#linux-debian)

#### 1. Update packages (recommended)

[](#1-update-packages-recommended)

Before installing, make sure your package lists are up to date:

```
sudo apt update
sudo apt upgrade
```

#### 2. Install the Memcached server

[](#2-install-the-memcached-server)

This installs the Memcached daemon, which handles in-memory caching:

```
$ sudo apt update
$ sudo apt install memcached
$ sudo apt install libmemcached-tools
```

Package descriptions:

- memcached — The Memcached server daemon.
- libmemcached-tools — Command-line utilities to interact with Memcached (e.g., for viewing statistics).

#### 3. Install memcflush (optional but useful)

[](#3-install-memcflush-optional-but-useful)

```
curl -O https://raw.githubusercontent.com/memcached/memcached/master/scripts/memcflush.pl
chmod +x memcflush.pl
sudo mv memcflush.pl /usr/local/bin/memcflush
```

#### 4. Verify Perl installation

[](#4-verify-perl-installation)

```
$ perl --version
```

#### 5. Start Memcached if necessary

[](#5-start-memcached-if-necessary)

```
$ sudo systemctl start memcached
```

#### 6. Configure the Memcached server (optional but recommended)

[](#6-configure-the-memcached-server-optional-but-recommended)

The main configuration file is:

```
sudo pico /etc/memcached.conf
```

Common parameters:

- -m 64 (ou -m 1024 par exemple) : Memory allocation in MB for Memcached (default is often 64 MB).
- -p 11211 : TCP port to listen on (default: 11211).
- -l 127.0.0.1 : Listening IP address. For security, keep this as 127.0.0.1 unless remote access is required (and firewall rules are properly set).
- -U 0 : Disables the UDP protocol to mitigate certain attacks.

After modifying the configuration file, restart Memcached:

```
sudo systemctl restart memcached
sudo systemctl enable memcached # Start automatically at boot
```

#### 7. Install the PHP Memcached extension

[](#7-install-the-php-memcached-extension)

```
sudo apt install php8.4-memcached
sudo systemctl restart nginx
sudo systemctl restart php8.4-fpm
```

If you have multiple PHP versions, ensure you install the extension for the version your application uses (e.g., php8.4-memcached for PHP 8.4).

Verify installation:

```

```

Open it in a browser and search for “memcached” — you should see a dedicated section showing it’s enabled.

You can also check via CLI:

```
php -m | grep memcached
```

#### 8. Verify Memcached is running

[](#8-verify-memcached-is-running)

```
echo "stats settings" | nc localhost 11211
```

#### 9. Secure Memcached

[](#9-secure-memcached)

##### Limit access to localhost

[](#limit-access-to-localhost)

By default, Memcached listens on 127.0.0.1 (localhost). Verify this setting:

```
sudo pico /etc/memcached.conf
```

Check for:

```
-l 127.0.0.1
```

This prevents external connections.

⚠️ Never expose Memcached directly to the internet.

### MacOS

[](#macos)

#### 1. Install Memcached and tools

[](#1-install-memcached-and-tools)

Make sure you have [Homebrew](https://brew.sh/) installed first.

```
brew install memcached
brew install libmemcached
```

#### 2. Install memcflush

[](#2-install-memcflush)

```
curl -O https://raw.githubusercontent.com/memcached/memcached/master/scripts/memcflush.pl
chmod +x memcflush.pl
sudo mv memcflush.pl /usr/local/bin/memcflush
```

#### 3. Verify Perl installation

[](#3-verify-perl-installation)

```
perl --version
```

#### 4. Test memflush

[](#4-test-memflush)

```
$ memflush --servers=localhost:11211
```

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance76

Regular maintenance activity

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~2 days

Total

4

Last Release

273d ago

### Community

Maintainers

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

---

Top Contributors

[![ekameleon](https://avatars.githubusercontent.com/u/749032?v=4)](https://github.com/ekameleon "ekameleon (30 commits)")

---

Tags

phpconsolememcachedcommand

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/oihana-php-memcached/health.svg)

```
[![Health](https://phpackages.com/badges/oihana-php-memcached/health.svg)](https://phpackages.com/packages/oihana-php-memcached)
```

###  Alternatives

[nunomaduro/termwind

It's like Tailwind CSS, but for the console.

2.5k239.8M286](/packages/nunomaduro-termwind)[nunomaduro/laravel-console-task

Laravel Console Task is a output method for your Laravel/Laravel Zero commands.

2582.1M11](/packages/nunomaduro-laravel-console-task)[alecrabbit/php-cli-snake

Lightweight cli spinner with zero dependencies

29211.3k5](/packages/alecrabbit-php-cli-snake)

PHPackages © 2026

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