Skip to content

Commit 1513dc3

Browse files
authored
Merge pull request #333 from Geolim4/final
Implemented #133
2 parents 0c167f9 + df78196 commit 1513dc3

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

examples/memcache.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,15 @@
1818
require __DIR__ . '/../vendor/autoload.php';
1919

2020
$InstanceCache = CacheManager::getInstance('memcache');
21-
// Or with compress_data option
22-
// $InstanceCache = CacheManager::getInstance('memcache', ['compress_data' => true]);
21+
/**
22+
* In case you need to enable compress_data option:
23+
* $InstanceCache = CacheManager::getInstance('memcache', ['compress_data' => true]);
24+
*
25+
* In case you need SASL authentication:
26+
* $InstanceCache = CacheManager::getInstance('memcache', ['sasl_user' => 'hackerman', 'sasl_password' => '12345']);
27+
* Warning: Memcache needs to be compiled with a specific option (--enable-memcached-sasl) to use sasl authentication, see:
28+
* http://php.net/manual/fr/memcached.installation.php
29+
*/
2330

2431
/**
2532
* Try to get $products from Caching First

examples/memcached.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
require __DIR__ . '/../vendor/autoload.php';
1919

2020
$InstanceCache = CacheManager::getInstance('memcached');
21+
/**
22+
* In case you need SASL authentication:
23+
* $InstanceCache = CacheManager::getInstance('memcache', ['sasl_user' => 'hackerman', 'sasl_password' => '12345']);
24+
* Warning: Memcache needs to be compiled with a specific option (--enable-memcached-sasl) to use sasl authentication, see:
25+
* http://php.net/manual/fr/memcached.installation.php
26+
*/
2127

2228
/**
2329
* Try to get $products from Caching First

src/phpFastCache/Drivers/Memcache/Driver.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ protected function driverConnect()
140140
if (!$this->instance->addserver($server[ 0 ], $server[ 1 ])) {
141141
$this->fallback = true;
142142
}
143+
if(!empty($server[ 'sasl_user' ]) && !empty($server[ 'sasl_password'])){
144+
$this->instance->setSaslAuthData($server[ 'sasl_user' ], $server[ 'sasl_password']);
145+
}
143146
} catch (\Exception $e) {
144147
$this->fallback = true;
145148
}

src/phpFastCache/Drivers/Memcached/Driver.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ protected function driverConnect()
139139
if (!$this->instance->addServer($server[ 0 ], $server[ 1 ])) {
140140
$this->fallback = true;
141141
}
142+
if(!empty($server[ 'sasl_user' ]) && !empty($server[ 'sasl_password'])){
143+
$this->instance->setSaslAuthData($server[ 'sasl_user' ], $server[ 'sasl_password']);
144+
}
142145
} catch (\Exception $e) {
143146
$this->fallback = true;
144147
}

0 commit comments

Comments
 (0)