Skip to content

Commit ab6109b

Browse files
committed
chore: Get cache lazily in OC\Memcache\Redis
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
1 parent 19a85a9 commit ab6109b

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

lib/private/Memcache/Redis.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,19 @@ class Redis extends Cache implements IMemcacheTTL {
3939

4040
private const MAX_TTL = 30 * 24 * 60 * 60; // 1 month
4141

42-
private \Redis|\RedisCluster $cache;
42+
private \Redis|\RedisCluster|null $cache = null;
4343

4444
public function __construct($prefix = '', string $logFile = '') {
4545
parent::__construct($prefix);
46-
$this->cache = \OCP\Server::get(RedisFactory::class)->getInstance();
4746
}
4847

4948
/**
5049
* @throws \Exception
5150
*/
5251
public function getCache(): \Redis|\RedisCluster {
52+
if ($this->cache === null) {
53+
$this->cache = \OCP\Server::get(RedisFactory::class)->getInstance();
54+
}
5355
return $this->cache;
5456
}
5557

0 commit comments

Comments
 (0)