Resolver problemas de conexión con servidor remoto de Memcache.

Implementando en un proyecto Memcache en un servidor independiente estaba devolviendo todo el rato el siguiente mensaje: Failed to store to then retrieve data from memcache.

La configuración básica del archivo settings.php era:

$conf['cache_backends'][] = 'sites/all/modules/contrib/memcache/memcache.inc';
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
$conf['memcache_key_prefix'] = 'wadus-unique-key';  // Una clave única para cada sitio
$conf['memcache_servers'] = array('ip:port' => 'default');

Como la configuración básica es correcta, y en local estaba funcionando correctamente, empecé a leer el README, y comprobé que la configuración del servidor era la correcta, ya que el módulo no devuelve el error Failed to connect to memcached server instance at <IP ADDRESS>.

Así que algo pasaba, la cuestión era descubrir el que, y para eso busqué en Google formas de conecttar con memcache, y las opciones que encontré y han funcionando son:

$ echo stats | nc 127.0.0.1 11211
STAT pid 22020
STAT uptime 3689364
STAT time 1227753109
STAT version 1.2.5
STAT pointer_size 64
STAT rusage_user 4543.071348
STAT rusage_system 8568.293421
STAT curr_items 139897
STAT total_items 51710845
STAT bytes 360147055
STAT curr_connections 40
STAT total_connections 66762
STAT connection_structures 327
STAT cmd_get 319992973
STAT cmd_set 51710845
STAT get_hits 280700485
STAT get_misses 39292488
STAT evictions 849165
STAT bytes_read 141320046298
STAT bytes_written 544357801590
STAT limit_maxbytes 402653184
STAT threads 4
END

Y la segunda forma de validar la conexión:

$ telnet port ip
Trying ip...
Connected to ip
Escape character is '^]'.
stats
STAT pid 987
STAT uptime 164
STAT time 1441027218
STAT version 1.4.13
STAT libevent 2.0.16-stable
STAT pointer_size 64
STAT rusage_user 0.016001
STAT rusage_system 0.016001
STAT curr_connections 5
STAT total_connections 9
STAT connection_structures 6
STAT reserved_fds 20
STAT cmd_get 0
STAT cmd_set 0
STAT cmd_flush 0
STAT cmd_touch 0
STAT get_hits 0
STAT get_misses 0
STAT delete_misses 0
STAT delete_hits 0
STAT incr_misses 0
STAT incr_hits 0
STAT decr_misses 0
STAT decr_hits 0
STAT cas_misses 0
STAT cas_hits 0
STAT cas_badval 0
STAT touch_hits 0
STAT touch_misses 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 27
STAT bytes_written 3070
STAT limit_maxbytes 536870912
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 4
STAT conn_yields 0
STAT hash_power_level 16
STAT hash_bytes 524288
STAT hash_is_expanding 0
STAT expired_unfetched 0
STAT evicted_unfetched 0
STAT bytes 0
STAT curr_items 0
STAT total_items 0
STAT evictions 0
STAT reclaimed 0
END

Oskar