diff options
author | Chad Kieffer <ckieffer@gmail.com> | 2009-06-28 17:57:23 -0600 |
---|---|---|
committer | Chad Kieffer <ckieffer@gmail.com> | 2009-06-28 17:57:23 -0600 |
commit | bf79d4372cbaac63f4fee55dbba58bc19f52bc14 (patch) | |
tree | d648c5d7d455da63b36f795f010cc94d55fe3ee5 /modules/gallery/libraries/drivers/Cache/Database.php | |
parent | 2b804ebdcea2127ca481ae3fb25a33a3bc5a78c3 (diff) | |
parent | ce6d453b3f32af98e13b62fe10b62173c59bde44 (diff) |
Merge branch 'master' of git@github.com:gallery/gallery3
Diffstat (limited to 'modules/gallery/libraries/drivers/Cache/Database.php')
-rw-r--r-- | modules/gallery/libraries/drivers/Cache/Database.php | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/modules/gallery/libraries/drivers/Cache/Database.php b/modules/gallery/libraries/drivers/Cache/Database.php index 70235e05..f3a1eb02 100644 --- a/modules/gallery/libraries/drivers/Cache/Database.php +++ b/modules/gallery/libraries/drivers/Cache/Database.php @@ -32,9 +32,8 @@ class Cache_Database_Driver implements Cache_Driver { $this->db = Database::instance(); if (!$this->db->table_exists("caches")) { - throw new Kohana_Exception("cache.driver_error", "Cache table is not defined"); + throw new Exception("@todo Cache table is not defined"); } - Kohana::log("debug", "Cache Database Driver Initialized"); } /** @@ -44,7 +43,7 @@ class Cache_Database_Driver implements Cache_Driver { * @return boolean */ public function exists($id) { - $count = $this->db->count_records("caches", array("id" => $id, "expiration >=" => time())); + $count = $this->db->count_records("caches", array("key" => $id, "expiration >=" => time())); return $count > 0; } @@ -68,13 +67,12 @@ class Cache_Database_Driver implements Cache_Driver { $lifetime += time(); } - $data = serialize($data); if ($this->exists($id)) { $status = $this->db->update("caches", - array("tags" => $tags, "expiration" => $lifetime, "cache" => $data), array("id" => $id)); + array("tags" => $tags, "expiration" => $lifetime, "cache" => $data), array("key" => $id)); } else { $status = $this->db->insert("caches", - array("id" => $id, "tags" => $tags, "expiration" => $lifetime, "cache" => $data)); + array("key" => $id, "tags" => $tags, "expiration" => $lifetime, "cache" => $data)); } return count($status) > 0; @@ -101,7 +99,7 @@ class Cache_Database_Driver implements Cache_Driver { foreach ($db_result as $row) { // Add each cache to the array - $result[$row->id] = unserialize($row->cache); + $result[$row->id] = $row->cache; } // Turn notices back on @@ -120,7 +118,7 @@ class Cache_Database_Driver implements Cache_Driver { */ public function get($id) { $data = null; - $result = $this->db->getwhere("caches", array("id" => $id)); + $result = $this->db->getwhere("caches", array("key" => $id)); if (count($result) > 0) { $cache = $result->current(); @@ -133,7 +131,7 @@ class Cache_Database_Driver implements Cache_Driver { $ER = error_reporting(~E_NOTICE); // Return the valid cache data - $data = unserialize($cache->cache); + $data = $cache->cache; // Turn notices back on error_reporting($ER); @@ -158,7 +156,7 @@ class Cache_Database_Driver implements Cache_Driver { } else if ($tag === true) { $this->db->like("tags", "<$id>"); } else { - $this->db->where("id", $id); + $this->db->where("key", $id); } $status = $this->db->delete(); |