Elgg  Version 2.3
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) || !is_memcache_available()) {
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 
29  if (empty($server_stats)) {
30  // memcache server not available
31  echo elgg_view_module('info', $server, elgg_echo('notfound'));
32  continue;
33  }
34 
35  $rows = [];
36 
37  foreach ($server_stats as $key => $value) {
38  $row = [];
39  $row[] = elgg_format_element('td', [], elgg_format_element('b', [], $key . ':'));
40  $row[] = elgg_format_element('td', [], $value);
41 
42  $rows[] = elgg_format_element('tr', [], implode(PHP_EOL, $row));
43  }
44 
45  $table = elgg_format_element('table', ['class' => 'elgg-table-alt'], implode(PHP_EOL, $rows));
46 
47  echo elgg_view_module('info', $server, $table);
48 }
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
$servers
Memcache info.
Definition: memcache.php:5
$table
Definition: cron.php:34
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
$value
Definition: longtext.php:42
elgg_format_element($tag_name, array $attributes=array(), $text= '', array $options=array())
Format an HTML element.
Definition: output.php:208
$key
Definition: summary.php:34
is_memcache_available()
Return true if memcache is available and configured.
Definition: memcache.php:16
elgg echo
Translates a string.
Definition: languages.js:48
elgg_view_module($type, $title, $body, array $vars=array())
Wrapper function for the module display pattern.
Definition: views.php:1250
$row
$rows