Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for connection timeout #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Extended/Cache/Backend/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class Extended_Cache_Backend_Redis extends Zend_Cache_Backend implements Zend_Ca
const DEFAULT_DBINDEX = 0;
const DEFAULT_AUTH = false;
const DEFAULT_AUTH_PASSWORD = null;
const DEFAULT_TIMEOUT = 0.0;

protected $_options = array(
'servers' => array(
Expand All @@ -73,6 +74,7 @@ class Extended_Cache_Backend_Redis extends Zend_Cache_Backend implements Zend_Ca
'dbindex' => self::DEFAULT_DBINDEX,
'auth' => self::DEFAULT_AUTH,
'password' => self::DEFAULT_AUTH_PASSWORD,
'timeout' => self::DEFAULT_TIMEOUT,
),
),
'key_prefix' => '',
Expand Down Expand Up @@ -111,10 +113,13 @@ public function __construct(array $options = array())
if (!array_key_exists('dbindex', $server)) {
$server['dbindex'] = self::DEFAULT_DBINDEX;
}
if (!array_key_exists('timeout', $server)) {
$server['timeout'] = self::DEFAULT_TIMEOUT;
}
if ($server['persistent']) {
$result = $this->_redis->pconnect($server['host'], $server['port']);
$result = $this->_redis->pconnect($server['host'], $server['port'], $server['timeout']);
} else {
$result = $this->_redis->connect($server['host'], $server['port']);
$result = $this->_redis->connect($server['host'], $server['port'], $server['timeout']);
}

if ($this->_redis && array_key_exists('auth', $server) && $server['auth']) {
Expand Down