diff options
Diffstat (limited to 'modules/gallery/libraries/drivers/Cache')
-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(); |