<!-- review: finished -->

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

# Enhanced Memcached

Este módulo estende as capacidades do módulo [Memcached](https://pt.angie.software//angie/docs/configuration/modules/http/http_memcached.md#http-memcached) integrado, permitindo adicionar e remover dados chave-valor no servidor memcached.

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

## Instalação

Para [instalar](https://pt.angie.software//angie/docs/installation/index.md#install-packages) o módulo, use um dos seguintes pacotes:

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

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

## Carregando o Módulo

Carregue o módulo no contexto `main{}`:

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

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

## Exemplo de Configuração

```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>

## Exemplos de Requisições

Adicionando uma chave `key1` com o valor `key1 value`:

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

Obtendo o valor de `key1`:

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

Excluindo os dados com chave `key1`:

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

Exibindo estatísticas do memcached:

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

Limpando todos os dados:

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

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

## Informações Adicionais

Documentação detalhada e código-fonte estão disponíveis em:
[https://github.com/bpaquet/ngx_http_enhanced_memcached_module](https://github.com/bpaquet/ngx_http_enhanced_memcached_module)
