diff --git a/airtime_mvc/application/models/Cache.php b/airtime_mvc/application/models/Cache.php new file mode 100644 index 000000000..3d89b0649 --- /dev/null +++ b/airtime_mvc/application/models/Cache.php @@ -0,0 +1,26 @@ +beginTransaction(); @@ -103,10 +107,29 @@ class Application_Model_Preference exit; } + $cache->store($key, $value, $userId); + Logging::info("SAVING {$key} {$userId} into cache. = {$value}"); } private static function getValue($key, $isUserValue = false) { + $cache = new Cache(); + + //For user specific preference, check if id matches as well + $userId = null; + if ($isUserValue) { + $auth = Zend_Auth::getInstance(); + if ($auth->hasIdentity()) { + $userId = $auth->getIdentity()->id; + } + } + + $res = $cache->fetch($key, $userId); + if ($res !== false) { + Logging::info("returning {$key} {$userId} from cache. = {$res}"); + return $res; + } + try { //Check if key already exists @@ -117,14 +140,10 @@ class Application_Model_Preference $paramMap[':key'] = $key; //For user specific preference, check if id matches as well - if ($isUserValue) { - $auth = Zend_Auth::getInstance(); - if ($auth->hasIdentity()) { - $id = $auth->getIdentity()->id; - - $sql .= " AND subjid = :id"; - $paramMap[':id'] = $id; - } + if (isset($userId)) { + + $sql .= " AND subjid = :id"; + $paramMap[':id'] = $userId; } $result = Application_Common_Database::prepareAndExecute($sql, $paramMap, Application_Common_Database::COLUMN); @@ -140,14 +159,17 @@ class Application_Model_Preference $paramMap[':key'] = $key; //For user specific preference, check if id matches as well - if ($isUserValue && $auth->hasIdentity()) { + if (isset($userId)) { $sql .= " AND subjid = :id"; - $paramMap[':id'] = $id; + $paramMap[':id'] = $userId; } $result = Application_Common_Database::prepareAndExecute($sql, $paramMap, Application_Common_Database::COLUMN); - return ($result !== false) ? $result : ""; + $res = ($result !== false) ? $result : ""; + $cache->store($key, $res, $userId); + + return $res; } } catch (Exception $e) { header('HTTP/1.0 503 Service Unavailable'); diff --git a/install_full/ubuntu/airtime-full-install b/install_full/ubuntu/airtime-full-install index 13d714407..066f4ab3a 100755 --- a/install_full/ubuntu/airtime-full-install +++ b/install_full/ubuntu/airtime-full-install @@ -59,7 +59,7 @@ libtaglib-ocaml libao-ocaml libmad-ocaml ecasound \ libesd0 libportaudio2 libsamplerate0 rabbitmq-server patch \ php5-curl mpg123 monit python-virtualenv multitail libcamomile-ocaml-data \ libpulse0 vorbis-tools lsb-release lsof sudo mp3gain vorbisgain flac vorbis-tools \ -pwgen libfaad2 +pwgen libfaad2 php-apc #install packages with --force-yes option (this is useful in the case