Elgg  Version 6.1
memcache.php
Go to the documentation of this file.
1 <?php
5 $servers = elgg_get_config('memcache_servers');
6 if (!elgg_get_config('memcache') || empty($servers) || !\Elgg\Cache\CompositeCache::isMemcacheAvailable()) {
7  echo '<p>' . elgg_echo('admin:server:memcache:inactive') . '</p>';
8  return;
9 }
10 
11 if (class_exists('Memcached')) {
12  $memcache = new Memcached();
13 } else {
14  $memcache = new Memcache();
15 }
16 
17 foreach ($servers as $server) {
18  $memcache->addserver($server['host'], $server['port']);
19 }
20 
21 if ($memcache instanceof Memcache) {
22  $stats = $memcache->getextendedstats();
23 } else {
24  $stats = $memcache->getStats();
25 }
26 
27 foreach ($stats as $server => $server_stats) {
28  if (empty($server_stats)) {
29  // memcache server not available
30  echo elgg_view_module('info', $server, elgg_echo('notfound'));
31  continue;
32  }
33 
34  $rows = [];
35 
36  foreach ($server_stats as $key => $value) {
37  $row = [];
38  $row[] = elgg_format_element('td', [], elgg_format_element('b', [], $key . ':'));
39  $row[] = elgg_format_element('td', [], $value);
40 
41  $rows[] = elgg_format_element('tr', [], implode(PHP_EOL, $row));
42  }
43 
44  $table = elgg_format_element('table', ['class' => 'elgg-table-alt'], implode(PHP_EOL, $rows));
45 
46  echo elgg_view_module('info', $server, $table);
47 }
elgg_view_module(string $type, string $title, string $body, array $vars=[])
Wrapper function for the module display pattern.
Definition: views.php:919
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
$servers
Memcache info.
Definition: memcache.php:5
$table
Definition: user.php:37
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:44
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition: output.php:145