summaryrefslogtreecommitdiff
path: root/classes/Status_network.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2009-11-11 00:22:42 -0500
committerEvan Prodromou <evan@status.net>2009-11-11 00:22:42 -0500
commit935410e8dc4c2d4d286a942cc27bbf8bc452fbdd (patch)
tree98e3a577b432232bdddcc30afa9ad8a61a28d301 /classes/Status_network.php
parent1f5f5474f175a8248b362f8be4ff23bb5e971305 (diff)
parent093857c582a68b39e0d65523d27f25ede7b7fed6 (diff)
Merge branch '0.9.x' into adminpanel
Diffstat (limited to 'classes/Status_network.php')
-rw-r--r--classes/Status_network.php28
1 files changed, 18 insertions, 10 deletions
diff --git a/classes/Status_network.php b/classes/Status_network.php
index fe4f0b0c5..b3117640d 100644
--- a/classes/Status_network.php
+++ b/classes/Status_network.php
@@ -57,14 +57,16 @@ class Status_network extends DB_DataObject
$config['db']['ini_'.$dbname] = INSTALLDIR.'/classes/status_network.ini';
$config['db']['table_status_network'] = $dbname;
- self::$cache = new Memcache();
+ if (class_exists('Memcache')) {
+ self::$cache = new Memcache();
- if (is_array($servers)) {
- foreach($servers as $server) {
- self::$cache->addServer($server);
+ if (is_array($servers)) {
+ foreach($servers as $server) {
+ self::$cache->addServer($server);
+ }
+ } else {
+ self::$cache->addServer($servers);
}
- } else {
- self::$cache->addServer($servers);
}
self::$base = $dbname;
@@ -76,6 +78,10 @@ class Status_network extends DB_DataObject
static function memGet($k, $v)
{
+ if (!self::$cache) {
+ return self::staticGet($k, $v);
+ }
+
$ck = self::cacheKey($k, $v);
$sn = self::$cache->get($ck);
@@ -92,10 +98,12 @@ class Status_network extends DB_DataObject
function decache()
{
- $keys = array('nickname', 'hostname', 'pathname');
- foreach ($keys as $k) {
- $ck = self::cacheKey($k, $this->$k);
- self::$cache->delete($ck);
+ if (self::$cache) {
+ $keys = array('nickname', 'hostname', 'pathname');
+ foreach ($keys as $k) {
+ $ck = self::cacheKey($k, $this->$k);
+ self::$cache->delete($ck);
+ }
}
}