<!-- review: finished -->

<a id="external-enhanced-memcached"></a>

# Enhanced Memcached

This module extends the capabilities of the built-in [Memcached](https://en.angie.software//angie/docs/configuration/modules/http/http_memcached.md#http-memcached) module, allowing you to add and remove key-value data on the memcached server.

<a id="installation-9"></a>

## Installation

To [install](https://en.angie.software//angie/docs/installation/index.md#install-packages) the module, use one of the following packages:

- Angie: `angie-module-enhanced-memcached`
- Angie PRO: `angie-pro-module-enhanced-memcached`

<a id="loading-the-module-9"></a>

## Loading the Module

Load the module in the `main{}` context:

```nginx
load_module modules/ngx_http_enhanced_memcached_module.so;
```

<a id="configuration-example-86"></a>

## Configuration Example

```nginx
upstream memcached_upstream {
    server 127.0.0.1:11211;
}

server {
    listen 80;
    server_name localhost;

    location / {
        set $enhanced_memcached_key "$request_uri";
        enhanced_memcached_allow_put on;
        enhanced_memcached_allow_delete on;
        enhanced_memcached_pass memcached_upstream;
    }

    location /stats {
        enhanced_memcached_stats on;
        enhanced_memcached_pass memcached_upstream;
        access_log off;
    }

    location /flush {
        enhanced_memcached_flush on;
        enhanced_memcached_pass memcached_upstream;
    }
}
```

<a id="request-examples"></a>

## Request Examples

Adding a key `key1` with the value `key1 value`:

```console
$ curl -X PUT -d 'key1 value' http://127.0.0.1/key1
STORED
```

Retrieving the value of `key1`:

```console
$ curl http://127.0.0.1/key1
key1 value
```

Deleting the data with key `key1`:

```console
$ curl -X DELETE http://127.0.0.1/key1
DELETED
```

Outputting memcached statistics:

```console
$ curl http://127.0.0.1/stats
```

Clearing all data:

```console
$ curl http://127.0.0.1/flush
```

<a id="additional-information-10"></a>

## Additional Information

Detailed documentation and source code are available at:
[https://github.com/bpaquet/ngx_http_enhanced_memcached_module](https://github.com/bpaquet/ngx_http_enhanced_memcached_module)
