summaryrefslogtreecommitdiff
path: root/lib/util.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/util.php')
-rw-r--r--lib/util.php22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/util.php b/lib/util.php
index 621fdc137..20fe4ced6 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -1727,4 +1727,24 @@ function common_message_form($content, $user, $to) {
common_element_end('p');
common_element_end('form');
-} \ No newline at end of file
+}
+
+function common_memcache() {
+ static $cache = NULL;
+ if (!common_config('memcached', 'enabled')) {
+ return NULL;
+ } else {
+ if (!$cache) {
+ $cache = new Memcache();
+ $servers = common_config('memcached', 'server');
+ if (is_array($servers)) {
+ foreach($servers as $server) {
+ $cache->addServer($server);
+ }
+ } else {
+ $cache->addServer($servers);
+ }
+ }
+ return $cache;
+ }
+}