Elgg  Version master
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  'useStaticItemCaching' => true,
31  'itemDetailedDate' => true,
32  'optPrefix' => $namespace,
33  ];
34  if (!empty($config->redis_options) && is_array($config->redis_options)) {
35  $options = array_merge($options, $config->redis_options);
36  }
37 
38  if (count($config->redis_servers) > 1) {
39  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');
40  }
41 
42  $server = $config->redis_servers[0];
43 
44  $options = array_merge($options, $server);
45 
46  return new self($options);
47  }
48 }
Configuration for redis fastcache driver.
Definition: Redis.php:13
$config
Advanced site settings, debugging section.
Definition: debugging.php:6
if($who_can_change_language=== 'nobody') elseif($who_can_change_language=== 'admin_only'&&!elgg_is_admin_logged_in()) $options
Definition: language.php:20
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