MDL-48468 cache: add support for port in server address

This commit is contained in:
Tomasz Sanecki
2016-10-30 13:34:43 +11:00
committed by Russell Smith
parent 68b1e13094
commit fd7bb5a8d9
+7 -1
View File
@@ -138,7 +138,13 @@ class cachestore_redis extends cache_store implements cache_is_key_aware, cache_
*/
protected function new_redis($server, $prefix = '') {
$redis = new Redis();
if ($redis->connect($server)) {
$port = null;
if (strpos($server, ':')) {
$serverconf = explode(':', $server);
$server = $serverconf[0];
$port = $serverconf[1];
}
if ($redis->connect($server, $port)) {
$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
if (!empty($prefix)) {
$redis->setOption(Redis::OPT_PREFIX, $prefix);