MDL-85336 cachestore_redis: Split connection and read timeouts
This commit is contained in:
@@ -70,5 +70,10 @@ class cachestore_redis_addinstance_form extends cachestore_addinstance_form {
|
||||
$form->addHelpButton('connectiontimeout', 'connectiontimeout', 'cachestore_redis');
|
||||
$form->setDefault('connectiontimeout', cachestore_redis::CONNECTION_TIMEOUT);
|
||||
$form->setType('connectiontimeout', PARAM_FLOAT);
|
||||
|
||||
$form->addElement('text', 'readtimeout', get_string('readtimeout', 'cachestore_redis'));
|
||||
$form->addHelpButton('readtimeout', 'readtimeout', 'cachestore_redis');
|
||||
$form->setDefault('readtimeout', cachestore_redis::CONNECTION_TIMEOUT);
|
||||
$form->setType('readtimeout', PARAM_FLOAT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,8 @@ $string['prefix_help'] = 'This prefix is used for all key names on the Redis ser
|
||||
$string['prefixinvalid'] = 'Invalid prefix. You can only use a-z A-Z 0-9-_.';
|
||||
$string['privacy:metadata:redis'] = 'The Redis cachestore plugin stores data briefly as part of its caching functionality. This data is stored on an Redis server where data is regularly removed.';
|
||||
$string['privacy:metadata:redis:data'] = 'The various data stored in the cache';
|
||||
$string['readtimeout'] = 'Read timeout';
|
||||
$string['readtimeout_help'] = 'This sets the number of seconds to wait for a read from the Redis server.';
|
||||
$string['serializer_igbinary'] = 'Igbinary serializer';
|
||||
$string['serializer_php'] = 'Default PHP serializer';
|
||||
$string['server'] = 'Server(s)';
|
||||
|
||||
Vendored
+19
-5
@@ -122,12 +122,19 @@ class cachestore_redis extends store implements
|
||||
|
||||
|
||||
/**
|
||||
* The number of seconds to wait for a connection or response from the Redis server.
|
||||
* The number of seconds to wait for a connection response from the Redis server.
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
protected $connectiontimeout = self::CONNECTION_TIMEOUT;
|
||||
|
||||
/**
|
||||
* The number of seconds to wait for a read from the Redis server.
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
protected $readtimeout = self::CONNECTION_TIMEOUT;
|
||||
|
||||
/**
|
||||
* Bytes read or written by last call to set()/get() or set_many()/get_many().
|
||||
*
|
||||
@@ -214,6 +221,9 @@ class cachestore_redis extends store implements
|
||||
if (array_key_exists('connectiontimeout', $configuration)) {
|
||||
$this->connectiontimeout = (float)$configuration['connectiontimeout'];
|
||||
}
|
||||
if (array_key_exists('readtimeout', $configuration)) {
|
||||
$this->readtimeout = (float)$configuration['readtimeout'];
|
||||
}
|
||||
if (array_key_exists('lockwait', $configuration)) {
|
||||
$this->lockwait = (int)$configuration['lockwait'];
|
||||
}
|
||||
@@ -296,7 +306,7 @@ class cachestore_redis extends store implements
|
||||
name: null,
|
||||
seeds: $trimmedservers,
|
||||
timeout: $this->connectiontimeout, // Timeout.
|
||||
read_timeout: $this->connectiontimeout, // Read timeout.
|
||||
read_timeout: $this->readtimeout, // Read timeout.
|
||||
persistent: true,
|
||||
auth: $password,
|
||||
context: !empty($opts) ? $opts : null,
|
||||
@@ -306,7 +316,7 @@ class cachestore_redis extends store implements
|
||||
null,
|
||||
$trimmedservers,
|
||||
$this->connectiontimeout,
|
||||
$this->connectiontimeout,
|
||||
$this->readtimeout,
|
||||
true, $password,
|
||||
!empty($opts) ? $opts : null,
|
||||
);
|
||||
@@ -320,7 +330,7 @@ class cachestore_redis extends store implements
|
||||
port: $port,
|
||||
timeout: $this->connectiontimeout, // Timeout.
|
||||
retry_interval: 100, // Retry interval.
|
||||
read_timeout: $this->connectiontimeout, // Read timeout.
|
||||
read_timeout: $this->readtimeout, // Read timeout.
|
||||
context: $opts,
|
||||
);
|
||||
} else {
|
||||
@@ -329,7 +339,7 @@ class cachestore_redis extends store implements
|
||||
$this->connectiontimeout,
|
||||
null,
|
||||
100,
|
||||
$this->connectiontimeout,
|
||||
$this->readtimeout,
|
||||
$opts,
|
||||
);
|
||||
}
|
||||
@@ -912,6 +922,7 @@ class cachestore_redis extends store implements
|
||||
'serializer' => $data->serializer,
|
||||
'compressor' => $data->compressor,
|
||||
'connectiontimeout' => $data->connectiontimeout,
|
||||
'readtimeout' => $data->readtimeout,
|
||||
'encryption' => $data->encryption,
|
||||
'cafile' => $data->cafile,
|
||||
'clustermode' => $data->clustermode,
|
||||
@@ -939,6 +950,9 @@ class cachestore_redis extends store implements
|
||||
if (!empty($config['connectiontimeout'])) {
|
||||
$data['connectiontimeout'] = $config['connectiontimeout'];
|
||||
}
|
||||
if (!empty($config['readtimeout'])) {
|
||||
$data['readtimeout'] = $config['readtimeout'];
|
||||
}
|
||||
if (!empty($config['encryption'])) {
|
||||
$data['encryption'] = $config['encryption'];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user