fixing File cache engine expire #3006

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5492 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2007-08-05 17:13:03 +00:00
parent c84bbea48b
commit 020841b989
2 changed files with 10 additions and 3 deletions

View file

@ -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;
}

View file

@ -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);
}