Skip to content

Commit

Permalink
Add support for host and port params in MemcachedEngine
Browse files Browse the repository at this point in the history
  • Loading branch information
josegonzalez committed Jan 29, 2015
1 parent 76d5e03 commit 8d0f6fa
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Cache/Engine/MemcachedEngine.php
Expand Up @@ -68,9 +68,11 @@ class MemcachedEngine extends CacheEngine
'compress' => false,
'duration' => 3600,
'groups' => [],
'host' => null,
'username' => null,
'password' => null,
'persistent' => false,
'port' => null,
'prefix' => 'cake_',
'probability' => 100,
'serialize' => 'php',
Expand Down Expand Up @@ -113,6 +115,14 @@ public function init(array $config = [])
}

parent::init($config);

if (!empty($config['host'])) {
if (empty($config['port'])) {
$config['servers'] = [$config['host']];
} else {
$config['servers'] = [sprintf('%s:%d', $config['host'], $config['port'])];
}
}

if (isset($config['servers'])) {
$this->config('servers', $config['servers'], false);
Expand Down

0 comments on commit 8d0f6fa

Please sign in to comment.