diff options
author | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-11-06 11:09:10 +0000 |
---|---|---|
committer | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-11-06 11:09:10 +0000 |
commit | b752befd19233618c7681ce29308cd485502dd5e (patch) | |
tree | 344fd1a812d0e18dcbf16168bf70b1645db456ee /engine/lib/memcache.php | |
parent | 4acff6b9c106ef73362dbb289fb2fade01c5f24d (diff) | |
download | elgg-b752befd19233618c7681ce29308cd485502dd5e.tar.gz elgg-b752befd19233618c7681ce29308cd485502dd5e.tar.bz2 |
Added test to see if memcache is available.
git-svn-id: https://code.elgg.org/elgg/trunk@2411 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/memcache.php')
-rw-r--r-- | engine/lib/memcache.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/engine/lib/memcache.php b/engine/lib/memcache.php index 8afef6302..ec3ebc783 100644 --- a/engine/lib/memcache.php +++ b/engine/lib/memcache.php @@ -213,4 +213,29 @@ $this->save_persistent_keylist(); }*/ } + + /** + * 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 (($memcache_available!==true) && ($memcache_available!==false)) // If we haven't set variable to something + { + try { + $tmp = new ElggMemcache(); + $memcache_available = true; // No exception thrown so we have memcache available + } catch (Exception $e) { $memcache_available = false; } + } + + return $memcache_available; + } ?>
\ No newline at end of file |