summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPaul Arthur <paul.arthur@flowerysong.com>2013-06-11 10:35:50 -0400
committerPaul Arthur <paul.arthur@flowerysong.com>2013-06-12 13:25:57 -0400
commit438a2a90233b2ef971a03b52f8ef29160b28ae19 (patch)
tree4da5f59250fe581283e8e49d85406fbb064040af /lib
parent0391d2443829ee0d92943c80ffcd918eafe53a6b (diff)
downloadampache-438a2a90233b2ef971a03b52f8ef29160b28ae19.tar.gz
ampache-438a2a90233b2ef971a03b52f8ef29160b28ae19.tar.bz2
ampache-438a2a90233b2ef971a03b52f8ef29160b28ae19.zip
Don't cache browses for the API
The API will never request it again, so caching the query just wastes space.
Diffstat (limited to 'lib')
-rw-r--r--lib/class/api.class.php2
-rw-r--r--lib/class/query.class.php43
2 files changed, 27 insertions, 18 deletions
diff --git a/lib/class/api.class.php b/lib/class/api.class.php
index b913c06d..86d6f5fb 100644
--- a/lib/class/api.class.php
+++ b/lib/class/api.class.php
@@ -50,7 +50,7 @@ class Api {
*/
public static function _auto_init() {
if (is_null(self::$browse)) {
- self::$browse = new Browse();
+ self::$browse = new Browse(null, false);
}
}
diff --git a/lib/class/query.class.php b/lib/class/query.class.php
index 84729b8f..d9161df1 100644
--- a/lib/class/query.class.php
+++ b/lib/class/query.class.php
@@ -43,18 +43,23 @@ class Query {
* constructor
* This should be called
*/
- public function __construct($id = null) {
+ public function __construct($id = null, $cached = true) {
$sid = Dba::escape(session_id());
-
+
if (is_null($id)) {
$this->reset();
- $data = Dba::escape(serialize($this->_state));
+ if ($cached) {
+ $data = Dba::escape(serialize($this->_state));
- $sql = "INSERT INTO `tmp_browse` (`sid`, `data`) " .
- "VALUES('$sid', '$data')";
- $db_results = Dba::write($sql);
- $this->id = Dba::insert_id();
+ $sql = "INSERT INTO `tmp_browse` (`sid`, `data`) " .
+ "VALUES('$sid', '$data')";
+ $db_results = Dba::write($sql);
+ $this->id = Dba::insert_id();
+ }
+ else {
+ $this->id = 'nocache';
+ }
return true;
}
@@ -1402,11 +1407,13 @@ class Query {
public function store() {
$sid = Dba::escape(session_id());
$id = Dba::escape($this->id);
- $data = Dba::escape(serialize($this->_state));
+ if ($id != 'nocache') {
+ $data = Dba::escape(serialize($this->_state));
- $sql = "UPDATE `tmp_browse` SET `data`='$data' " .
- "WHERE `sid`='$sid' AND `id`='$id'";
- $db_results = Dba::write($sql);
+ $sql = "UPDATE `tmp_browse` SET `data`='$data' " .
+ "WHERE `sid`='$sid' AND `id`='$id'";
+ $db_results = Dba::write($sql);
+ }
}
/**
@@ -1420,17 +1427,19 @@ class Query {
// a local variable and then second holds it in a row in the
// tmp_browse table
- // Only do this if it's a not a simple browse
- if (!$this->is_simple()) {
+ // Only do this if it's not a simple browse
+ if (!$this->is_simple()) {
$this->_cache = $object_ids;
$this->set_total(count($object_ids));
$sid = Dba::escape(session_id());
$id = Dba::escape($this->id);
- $data = Dba::escape(serialize($this->_cache));
+ if ($id != 'nocache') {
+ $data = Dba::escape(serialize($this->_cache));
- $sql = "UPDATE `tmp_browse` SET `object_data`='$data' " .
- "WHERE `sid`='$sid' AND `id`='$id'";
- $db_results = Dba::write($sql);
+ $sql = "UPDATE `tmp_browse` SET `object_data`='$data' " .
+ "WHERE `sid`='$sid' AND `id`='$id'";
+ $db_results = Dba::write($sql);
+ }
} // save it
return true;