File tree Expand file tree Collapse file tree 4 files changed +21
-2
lines changed Expand file tree Collapse file tree 4 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 1818require __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
Original file line number Diff line number Diff line change 1818require __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
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments