diff --git a/cake/libs/cache.php b/cake/libs/cache.php index e0253b83f..a5453d94f 100644 --- a/cake/libs/cache.php +++ b/cake/libs/cache.php @@ -143,7 +143,7 @@ class Cache extends Object { if (is_resource($value)) { return false; } - $duration = ife(is_string($duration), strtotime($duration), intval($duration)); + $duration = ife(is_string($duration), strtotime($duration) - time(), intval($duration)); if ($duration < 1) { return false; } diff --git a/cake/tests/cases/libs/cache/file.test.php b/cake/tests/cases/libs/cache/file.test.php index 5edc511ee..12ea74bb3 100644 --- a/cake/tests/cases/libs/cache/file.test.php +++ b/cake/tests/cases/libs/cache/file.test.php @@ -66,14 +66,21 @@ class FileEngineTest extends UnitTestCase { $result = Cache::read('other_test'); $this->assertFalse($result); + $data = 'this is a test of the emergency broadcasting system'; + $result = Cache::write('other_test', $data, "+1 second"); + $this->assertTrue($result); + + sleep(2); + $result = Cache::read('other_test'); + $this->assertFalse($result); } function testDeleteCache() { $data = 'this is a test of the emergency broadcasting system'; - $result = Cache::write('test', $data); + $result = Cache::write('delete_test', $data); $this->assertTrue($result); - $result = Cache::delete('test'); + $result = Cache::delete('delete_test'); $this->assertTrue($result); }