diff --git a/cache/stores/redis/lib.php b/cache/stores/redis/lib.php index 4d3d1a622f9a7..baa5953f2589c 100644 --- a/cache/stores/redis/lib.php +++ b/cache/stores/redis/lib.php @@ -65,9 +65,6 @@ class cachestore_redis extends store implements */ const TTL_EXPIRE_BATCH = 10000; - /** @var int The number of seconds to wait for a connection or response from the Redis server. */ - const CONNECTION_TIMEOUT = 10; - /** * Name of this store. * @@ -133,6 +130,13 @@ class cachestore_redis extends store implements /** @var ?array Array of current locks, or null if we haven't registered shutdown function */ protected $currentlocks = null; + /** + * The number of seconds to wait for a connection or response from the Redis server. + * + * @var int + */ + protected $connectiontimeout = 3; + /** * Determines if the requirements for this type of store are met. * @@ -203,6 +207,9 @@ public function __construct( if (array_key_exists('locktimeout', $configuration)) { $this->locktimeout = (int)$configuration['locktimeout']; } + if ($connectiontimeout = get_config('cachestore_redis', 'connectiontimeout')) { + $this->connectiontimeout = $connectiontimeout; + } $this->redis = $this->new_redis($configuration); }