Elgg  Version master
redis.php
Go to the documentation of this file.
1 <?php
5 $servers = elgg_get_config('redis_servers');
6 if (!elgg_get_config('redis') || empty($servers) || !\Elgg\Cache\CompositeCache::isRedisAvailable()) {
7  echo '<p>' . elgg_echo('admin:server:redis:inactive') . '</p>';
8 
9  return;
10 }
11 
12 $redis = new Redis();
13 
14 foreach ($servers as $server) {
15  $redis->connect($server['host'], $server['port']);
16 }
17 
18 $password = elgg_extract('password', elgg_get_config('redis_options'));
19 if (!empty($password)) {
20  $redis->auth($password);
21 }
22 
23 $stats = $redis->info();
24 
25 $rows = [];
26 
27 foreach ($stats as $key => $value) {
28  $row = [];
29  $row[] = elgg_format_element('td', [], elgg_format_element('b', [], $key . ':'));
30  $row[] = elgg_format_element('td', [], $value);
31 
32  $rows[] = elgg_format_element('tr', [], implode(PHP_EOL, $row));
33 }
34 
35 echo elgg_format_element('table', ['class' => 'elgg-table-alt'], implode(PHP_EOL, $rows));
elgg_get_config(string $name, $default=null)
Get an Elgg configuration value.
$rows
Definition: redis.php:25
if(!empty($password)) $stats
Definition: redis.php:23
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
$value
Definition: generic.php:51
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:254
if(!elgg_get_config('redis')||empty($servers)||!\Elgg\Cache\CompositeCache::isRedisAvailable()) $redis
Definition: redis.php:12
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:44
$servers
Redis info.
Definition: redis.php:5
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition: output.php:145
foreach($servers as $server) $password
Definition: redis.php:18