aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/memcache.php
blob: df65adc8aabf4739ef3c008ab40175e5548984b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
/**
 * Elgg memcache support.
 *
 * Requires php5-memcache to work.
 *
 * @package Elgg
 * @subpackage API
 */

/**
 * Return true if memcache is available and configured.
 *
 * @return bool
 */
function is_memcache_available() {
	global $CONFIG;

	static $memcache_available;

	if ((!isset($CONFIG->memcache)) || (!$CONFIG->memcache)) {
		return false;
	}

	// If we haven't set variable to something
	if (($memcache_available!==true) && ($memcache_available!==false))  {
		try {
			$tmp = new ElggMemcache();
			// No exception thrown so we have memcache available
			$memcache_available = true;
		} catch (Exception $e) {
			$memcache_available = false;
		}
	}

	return $memcache_available;
}