mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-65941 cache: Prevent cache config failure on redis problems.
This commit is contained in:
parent
d330035f11
commit
2385ae7ee2
32
cache/stores/redis/lib.php
vendored
32
cache/stores/redis/lib.php
vendored
@ -182,22 +182,28 @@ class cachestore_redis extends cache_store implements cache_is_key_aware, cache_
|
||||
$server = $serverconf[0];
|
||||
$port = $serverconf[1];
|
||||
}
|
||||
if ($redis->connect($server, $port)) {
|
||||
if (!empty($password)) {
|
||||
$redis->auth($password);
|
||||
|
||||
try {
|
||||
if ($redis->connect($server, $port)) {
|
||||
if (!empty($password)) {
|
||||
$redis->auth($password);
|
||||
}
|
||||
// If using compressor, serialisation will be done at cachestore level, not php-redis.
|
||||
if ($this->compressor == self::COMPRESSOR_NONE) {
|
||||
$redis->setOption(Redis::OPT_SERIALIZER, $this->serializer);
|
||||
}
|
||||
if (!empty($prefix)) {
|
||||
$redis->setOption(Redis::OPT_PREFIX, $prefix);
|
||||
}
|
||||
// Database setting option...
|
||||
$this->isready = $this->ping($redis);
|
||||
} else {
|
||||
$this->isready = false;
|
||||
}
|
||||
// If using compressor, serialisation will be done at cachestore level, not php-redis.
|
||||
if ($this->compressor == self::COMPRESSOR_NONE) {
|
||||
$redis->setOption(Redis::OPT_SERIALIZER, $this->serializer);
|
||||
}
|
||||
if (!empty($prefix)) {
|
||||
$redis->setOption(Redis::OPT_PREFIX, $prefix);
|
||||
}
|
||||
// Database setting option...
|
||||
$this->isready = $this->ping($redis);
|
||||
} else {
|
||||
} catch (\RedisException $e) {
|
||||
$this->isready = false;
|
||||
}
|
||||
|
||||
return $redis;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user