summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrokZlender2017-04-12 19:07:02 (GMT)
committerDamian Lee2017-04-12 19:07:02 (GMT)
commit0e4ef4d6134bdbc6e0ee9c7e85a6cd060bcdea83 (patch)
treec02e0a62beeb95cc981983ae53645b13864edb9f
parent01d903e04bfd9eb32dd4d1d74990ebbd3ee8e593 (diff)
Issue #2862230 by Rok ┼Żlender: SASL Support in Drupal 8 version
-rw-r--r--README.txt23
-rw-r--r--src/DrupalMemcached.php6
2 files changed, 29 insertions, 0 deletions
diff --git a/README.txt b/README.txt
index ace9a96..8868549 100644
--- a/README.txt
+++ b/README.txt
@@ -225,3 +225,26 @@ Other options you could experiment with:
reported that this can speed up the Binary protocol (see above). This
tells the TCP stack to send packets immediately and without waiting for
a full payload, reducing per-packet network latency (disabling "Nagling").
+
+It's possible to enable SASL authentication as documented here:
+ http://php.net/manual/en/memcached.setsaslauthdata.php
+ https://code.google.com/p/memcached/wiki/SASLHowto
+
+SASL authentication requires a memcached server with SASL support (version 1.4.3
+or greater built with --enable-sasl and started with the -S flag) and the PECL
+memcached client version 2.0.0 or greater also built with SASL support. Once
+these requirements are satisfied you can then enable SASL support in the Drupal
+memcache module by enabling the binary protocol and setting
+memcache_sasl_username and memcache_sasl_password in settings.php. For example:
+
+$settings['memcache']['sasl'] = [
+ 'username' => 'user',
+ 'password' => 'password',
+];
+
+// When using SASL, Memcached extension needs to be used
+// because Memcache extension doesn't support it.
+$settings['memcache']['extension'] = 'Memcached';
+$settings['memcache']['options'] = [
+ \Memcached::OPT_BINARY_PROTOCOL => TRUE,
+];
diff --git a/src/DrupalMemcached.php b/src/DrupalMemcached.php
index 2d3c88b..7201b0b 100644
--- a/src/DrupalMemcached.php
+++ b/src/DrupalMemcached.php
@@ -32,6 +32,12 @@ class DrupalMemcached extends DrupalMemcacheBase {
foreach ($this->settings->get('options', []) as $key => $value) {
$this->memcache->setOption($key, $value);
}
+
+ // SASL configuration to authenticate with Memcached.
+ // Note: this only affects the Memcached PECL extension.
+ if ($sasl_config = $this->settings->get('sasl', [])) {
+ $this->memcache->setSaslAuthData($sasl_config['username'], $sasl_config['password']);
+ }
}
/**