mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
test: verify touch refreshes stale entries
This commit is contained in:
1 parent
c6293e25f0
commit
bef0ec00c4
2 files changed
+4
-17
No files matched your search
@@ -62,8 +62,11 @@ abstract class Base extends TestCase
|
||||
$result = self::$cache->save('touch-key', 'touch data', 'touch-key');
|
||||
$this->assertEquals('touch data', $result);
|
||||
|
||||
sleep(2);
|
||||
|
||||
$this->assertEquals(false, self::$cache->load('touch-key', 1, 'touch-key'));
|
||||
$this->assertEquals(true, self::$cache->touch('touch-key', 'touch-key'));
|
||||
$this->assertEquals('touch data', self::$cache->load('touch-key', 60, 'touch-key'));
|
||||
$this->assertEquals('touch data', self::$cache->load('touch-key', 1, 'touch-key'));
|
||||
$this->assertEquals(false, self::$cache->touch('missing-touch-key', 'missing-touch-key'));
|
||||
|
||||
self::$cache->purge('touch-key');
|
||||
|
||||
@@ -20,20 +20,4 @@ class MemoryTest extends Base
|
||||
self::$cache->save('test:file36', 'file36');
|
||||
$this->assertEquals(4, self::$cache->getSize());
|
||||
}
|
||||
|
||||
public function testTouchExpiredEntry(): void
|
||||
{
|
||||
$adapter = new Memory();
|
||||
$cache = new Cache($adapter);
|
||||
|
||||
$cache->save('expired-touch-key', 'expired data');
|
||||
/** @var array{time: int, data: string} $stored */
|
||||
$stored = $adapter->store['expired-touch-key'];
|
||||
$stored['time'] = time() - 10;
|
||||
$adapter->store['expired-touch-key'] = $stored;
|
||||
|
||||
$this->assertEquals(false, $cache->load('expired-touch-key', 1));
|
||||
$this->assertEquals(true, $cache->touch('expired-touch-key'));
|
||||
$this->assertEquals('expired data', $cache->load('expired-touch-key', 1));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user