Elgg  Version 4.3
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_deprecated_notice("Multiple Redis servers are not supported. Only the first server will be used. Please update the configuration in elgg-config/settings.php", '4.2');
41  }
42 
43  $server = $config->redis_servers[0];
44  if (!array_key_exists('host', $server)) {
45  // assume old config syntax
46  elgg_deprecated_notice("Redis server({$server[0]}) configuration format has been changed. Please update the configuration in elgg-config/settings.php", '4.2');
47  $options['host'] = $server[0];
48  $options['port'] = $server[1];
49  } else {
50  $options = array_merge($options, $server);
51  }
52 
53  return new self($options);
54  }
55 }
Configuration for redis fastcache driver.
Definition: Redis.php:13
$server
elgg_deprecated_notice(string $msg, string $dep_version)
Log a notice about deprecated use of a function, view, etc.
Definition: deprecation.php:52
$options
Elgg admin footer.
Definition: footer.php:6
$config
Advanced site settings, debugging section.
Definition: debugging.php:6
static fromElggConfig(string $namespace,\Elgg\Config $config)
Factory to return a config object to be used when starting a driver.
Definition: Redis.php:23