summaryrefslogtreecommitdiffstats
path: root/lib/class
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-05-12 06:01:23 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-05-12 06:01:23 +0000
commitb69c3a0ec66997f9045c9fbecada3e38da55c3dd (patch)
tree5caf6c906d34e3a1e20803f051d8756855e635b7 /lib/class
parent3634ba80946b818de7f0505ed44d947e70dd41ec (diff)
downloadampache-b69c3a0ec66997f9045c9fbecada3e38da55c3dd.tar.gz
ampache-b69c3a0ec66997f9045c9fbecada3e38da55c3dd.tar.bz2
ampache-b69c3a0ec66997f9045c9fbecada3e38da55c3dd.zip
wups forgot an important file
Diffstat (limited to 'lib/class')
-rw-r--r--lib/class/database_object.abstract.php73
1 files changed, 73 insertions, 0 deletions
diff --git a/lib/class/database_object.abstract.php b/lib/class/database_object.abstract.php
new file mode 100644
index 00000000..5aaf6cac
--- /dev/null
+++ b/lib/class/database_object.abstract.php
@@ -0,0 +1,73 @@
+<?php
+/*
+
+ Copyright (c) Ampache.org
+ All rights reserved.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License v2
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * database_object
+ * This is a general object that is extended by all of the basic
+ * database based objects in ampache. It attempts to do some standard
+ * caching for all of the objects to cut down on the database calls
+ */
+abstract class database_object {
+
+ private static $object_cache = array();
+
+ // Statistics for debugging
+ public static $cache_hit = 0;
+
+ /**
+ * is_cached
+ * this checks the cache to see if the specified object is there
+ */
+ public static function is_cached($index,$id) {
+
+ $is_array = isset(self::$object_cache[$index][$id]);
+
+ return $is_array;
+
+ } // is_cached
+
+ /**
+ * get_from_cache
+ * This attempts to retrive the specified object from the cache we've got here
+ */
+ public static function get_from_cache($index,$id) {
+
+ if (isset(self::$object_cache[$index][$id])) {
+ self::$cache_hit++;
+ return self::$object_cache[$index][$id];
+ }
+
+ return false;
+
+ } // get_from_cache
+
+ /**
+ * add_to_cache
+ * This adds the specified object to the specified index in the cache
+ */
+ public static function add_to_cache($index,$id,$data) {
+
+ self::$object_cache[$index][$id] = $data;
+
+ return true;
+
+ } // add_to_cache
+
+} // end database_object