Elgg  Version 5.1
Redis.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Cache\Config;
4 
6 
13 class Redis extends Config {
14 
23  public static function fromElggConfig(string $namespace, \Elgg\Config $config): ?self {
24 
25  if (!$config->redis || empty($config->redis_servers) || !is_array($config->redis_servers)) {
26  return null;
27  }
28 
29  $options = [
30  'preventCacheSlams' => true,
31  'useStaticItemCaching' => true,
32  'itemDetailedDate' => true,
33  'optPrefix' => $namespace,
34  ];
35  if (!empty($config->redis_options) && is_array($config->redis_options)) {
36  $options = $config->redis_options;
37  }
38 
39  if (count($config->redis_servers) > 1) {
40  elgg_log('Multiple Redis servers are not supported. Only the first server will be used. Please update the configuration in elgg-config/settings.php', 'warning');
41  }
42 
43  $server = $config->redis_servers[0];
44 
45  $options = array_merge($options, $server);
46 
47  return new self($options);
48  }
49 }
Configuration for redis fastcache driver.
Definition: Redis.php:13
$server
$options
Elgg admin footer.
Definition: footer.php:6
$config
Advanced site settings, debugging section.
Definition: debugging.php:6
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
Definition: elgglib.php:86
static fromElggConfig(string $namespace,\Elgg\Config $config)
Factory to return a config object to be used when starting a driver.
Definition: Redis.php:23