I have set up an account with Redis Labs and created a Memcachd server. To authenticate, I need to use a SASL username and password.

I got errors both in the install file - the requirements were not met; and when trying to access the cache bins.

The .install file

I needed to add support for the sasl_auth user ID and the sasl_auth password. As SASL authentication only works with the binary protocol enabled, I had to set that option.

DrupalMemcached.php

This file already provided support for the sasl_auth user ID and sasl_auth password - but did not enforce the required binary protocol.

DrupalMemcachedBase.php

I needed to add support for the sasl_auth user ID and the sasl_auth password. As SASL authentication only works with the binary protocol enabled, I had to set that option.

DrupalMemcachedDebug.php

Here I fixed an unrelated bug that overwrote the value of a variable with a string - but then tried to re-use the original value of that variable.

Results

I am now getting cache hits and results

ACTION   TOTAL TIME, MS        TOTAL HITS / %        TOTAL MISSES / %
get              458.12            40 / 97.6%                1 / 2.4%
getMulti           9.48            9 / 100.0%                0 / 0.0%

settings.php

// Sets default cache storage as Memcache and excludes database connection for cache
$settings['cache']['default'] = 'cache.backend.memcache_storage';
// Sets Memcache key prefix for your site and useful in working sites with same memcache as backend.
$settings['memcache_storage']['key_prefix'] = '';
// Sets Memcache storage servers.
$settings['memcache_storage']['memcached_servers'] =  ['memcached-hostname.example.com:12345' => 'default'];

// Memcache settings
$settings['cache']['bins']['bootstrap'] = 'cache.backend.memcache_storage';
$settings['cache']['bins']['discovery'] = 'cache.backend.memcache_storage';
$settings['cache']['bins']['config'] = 'cache.backend.memcache_storage';

// Enables to display total hits and misses
$settings['memcache_storage']['debug'] = TRUE;

$settings['memcache_storage']['sasl_auth'] = [
  'user' => '** username **',
  'password' => '** password **',
];

// When using SASL, Memcached extension needs to be used
// because Memcache extension doesn't support it.
$settings['memcache_storage']['extension'] = 'Memcached';

$settings['memcache_storage']['memcached_options'] = [
  \Memcached::OPT_BINARY_PROTOCOL => TRUE,
  \Memcached::OPT_TCP_NODELAY => TRUE,
  \Memcached::OPT_COMPRESSION => FALSE,
  \Memcached::OPT_DISTRIBUTION => \Memcached::DISTRIBUTION_CONSISTENT,
];
CommentFileSizeAuthor
#2 memcache_storage-3028644.patch3.49 KBpaddy_deburca

Comments

paddy_deburca created an issue. See original summary.

paddy_deburca’s picture

StatusFileSize
new3.49 KB
paddy_deburca’s picture

For some extra information, in my settings.php file I have the following entries

$settings['cache']['default'] = 'cache.backend.memcache_storage';
// Sets Memcache key prefix for your site and useful in working sites with same memcache as backend.
$settings['memcache_storage']['key_prefix'] = '';
$settings['memcache_storage']['memcached_servers'] =  ['memcached-hostname.example.com:123456' => 'default'];
$settings['cache']['bins']['bootstrap'] = 'cache.backend.memcache_storage';
$settings['cache']['bins']['discovery'] = 'cache.backend.memcache_storage';
$settings['cache']['bins']['config'] = 'cache.backend.memcache_storage';
$settings['memcache_storage']['debug'] = TRUE;
$settings['memcache_storage']['sasl_auth'] = [
  'user' => '**username**',
  'password' => '**password**',
];
$settings['memcache_storage']['extension'] = 'Memcached';
$settings['memcache_storage']['memcached_options'] = [
  \Memcached::OPT_BINARY_PROTOCOL => TRUE,
  \Memcached::OPT_TCP_NODELAY => TRUE,
  \Memcached::OPT_COMPRESSION => FALSE,
  \Memcached::OPT_DISTRIBUTION => \Memcached::DISTRIBUTION_CONSISTENT,
];
paddy_deburca’s picture

Issue summary: View changes