Skip to content

Commit

Permalink
MDL-83753 cachestore_redis: Allow for configurable connection timeout…
Browse files Browse the repository at this point in the history
… setting
  • Loading branch information
djarran committed Dec 17, 2024
1 parent 81ac90b commit 80b42e3
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions cache/stores/redis/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 80b42e3

Please sign in to comment.