Skip to content

Commit

Permalink
Add unix socket support to Redis cache engine
Browse files Browse the repository at this point in the history
Refs #3438
  • Loading branch information
DIDoS authored and markstory committed May 12, 2014
1 parent 63ab865 commit cd445f2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/Cake/Cache/Engine/RedisEngine.php
Expand Up @@ -38,6 +38,7 @@ class RedisEngine extends CacheEngine {
* - port = integer port number to the Redis server (default: 6379)
* - timeout = float timeout in seconds (default: 0)
* - persistent = boolean Connects to the Redis server with a persistent connection (default: true)
* - unix_socket = path to the unix socket file (default: false)
*
* @var array
*/
Expand All @@ -64,7 +65,8 @@ public function init($settings = array()) {
'port' => 6379,
'password' => false,
'timeout' => 0,
'persistent' => true
'persistent' => true,
'unix_socket' => false
), $settings)
);

Expand All @@ -80,7 +82,9 @@ protected function _connect() {
$return = false;
try {
$this->_Redis = new Redis();
if (empty($this->settings['persistent'])) {
if (!empty($this->settings['unix_socket'])) {
$return = $this->_Redis->connect($this->settings['unix_socket']);
} elseif (empty($this->settings['persistent'])) {
$return = $this->_Redis->connect($this->settings['server'], $this->settings['port'], $this->settings['timeout']);
} else {
$persistentId = $this->settings['port'] . $this->settings['timeout'] . $this->settings['database'];
Expand Down

0 comments on commit cd445f2

Please sign in to comment.