diff options
author | Bharat Mediratta <bharat@menalto.com> | 2010-09-18 17:46:28 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2010-09-18 17:46:28 -0700 |
commit | fad1f05203f9c45b759fd0f4731e9025bca86114 (patch) | |
tree | be8834ef7c31c534ea7b48cb73879fdb4690f47e /modules | |
parent | a1b1d323af458958c9e06c8160bffb97882b8d41 (diff) |
The Kohana folks removed the cache cleanup code back in
http://dev.kohanaframework.org/projects/kohana2/repository/revisions/4605
So now our cache entries don't expire. For now, do cache expiration
whenever we render Admin > Maintenance, since that's the type of place
that users will go when they want their cache to expire anyway.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gallery/controllers/admin_maintenance.php | 7 | ||||
-rw-r--r-- | modules/gallery/libraries/drivers/Cache/Database.php | 14 | ||||
-rw-r--r-- | modules/gallery/tests/Cache_Test.php | 20 |
3 files changed, 7 insertions, 34 deletions
diff --git a/modules/gallery/controllers/admin_maintenance.php b/modules/gallery/controllers/admin_maintenance.php index a9cc933c..7729d797 100644 --- a/modules/gallery/controllers/admin_maintenance.php +++ b/modules/gallery/controllers/admin_maintenance.php @@ -48,6 +48,13 @@ class Admin_Maintenance_Controller extends Admin_Controller { $view->content->finished_tasks = ORM::factory("task") ->where("done", "=", 1)->order_by("updated", "DESC")->find_all(); print $view; + + // Do some maintenance while we're in here + db::build() + ->delete("caches") + ->where("expiration", "<>", 0) + ->where("expiration", "<=", time()) + ->execute(); } /** diff --git a/modules/gallery/libraries/drivers/Cache/Database.php b/modules/gallery/libraries/drivers/Cache/Database.php index 9ada52e1..b7822811 100644 --- a/modules/gallery/libraries/drivers/Cache/Database.php +++ b/modules/gallery/libraries/drivers/Cache/Database.php @@ -179,20 +179,6 @@ class Cache_Database_Driver extends Cache_Driver { } /** - * Deletes all cache files that are older than the current time. - */ - public function delete_expired() { - // Delete all expired caches - $status = db::build() - ->delete("caches") - ->where("expiration", "<>", 0) - ->where("expiration", "<=", time()) - ->execute(); - - return count($status) > 0; - } - - /** * Empty the cache */ public function delete_all() { diff --git a/modules/gallery/tests/Cache_Test.php b/modules/gallery/tests/Cache_Test.php index 4c65698a..e8d8b6f4 100644 --- a/modules/gallery/tests/Cache_Test.php +++ b/modules/gallery/tests/Cache_Test.php @@ -85,26 +85,6 @@ class Cache_Test extends Gallery_Unit_Test_Case { $this->assert_equal(array($id3 => $value3), $data, "Expected id3"); } - public function cache_delete_expired_test() { - $id1 = md5(rand()); - $value1 = array("field1" => "value1", "field2" => "value2"); - $this->_driver->set(array($id1 => $value1), array("tag1", "tag2"), -84600); - - $id2 = md5(rand()); - $value2 = array("field3" => "value3", "field4" => "value4"); - $this->_driver->set(array($id2 => $value2), array("tag2", "tag3"), -846000); - - $id3 = md5(rand()); - $value3 = array("field5" => "value5", "field6" => "value6"); - $this->_driver->set(array($id3 => $value3), array("tag3", "tag4"), -84600); - - $data = $this->_driver->delete_expired(); - - $this->assert_false($this->_driver->exists($id1), "$id1 should have been deleted"); - $this->assert_false($this->_driver->exists($id2), "$id2 should have been deleted"); - $this->assert_false($this->_driver->exists($id3), "$id3 should have been deleted"); - } - public function cache_delete_id_test() { $id1 = md5(rand()); $value1 = array("field1" => "value1", "field2" => "value2"); |