Elgg  Version 3.0
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) || !\Stash\Driver\Memcache::isAvailable()) {
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[0], $server[1]);
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 }
$rows
Definition: redis.php:20
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
$servers
Memcache info.
Definition: memcache.php:5
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:168
elgg_view_module($type, $title, $body, array $vars=[])
Wrapper function for the module display pattern.
Definition: views.php:1198
elgg echo
Translates a string.
Definition: languages.js:43
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:55
$value
Definition: debugging.php:7
foreach($servers as $server) $stats
Definition: redis.php:18
$table
Definition: cron.php:57
elgg_get_config($name, $default=null)
Get an Elgg configuration value.