fix(caching): properly respect ttl for all cache levels
This commit is contained in:
18
test/test.ts
18
test/test.ts
@ -21,7 +21,23 @@ tap.test('should cache a value', async () => {
|
||||
})
|
||||
);
|
||||
const result = await testLevelCache.retrieveCacheEntryByKey('mykey');
|
||||
console.log(result);
|
||||
expect(result.contents.toString()).to.equal('heythere');
|
||||
});
|
||||
|
||||
tap.test('should respect ttl', async (tools) => {
|
||||
await testLevelCache.storeCacheEntryByKey(
|
||||
'mykey',
|
||||
new CacheEntry({
|
||||
contents: Buffer.from('heythere'),
|
||||
ttl: 1000,
|
||||
typeInfo: 'string',
|
||||
})
|
||||
);
|
||||
const result = await testLevelCache.retrieveCacheEntryByKey('mykey');
|
||||
expect(result.contents.toString()).to.equal('heythere');
|
||||
await tools.delayFor(1100);
|
||||
const result2 = await testLevelCache.retrieveCacheEntryByKey('mykey');
|
||||
expect(result2).to.be.null;
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
Reference in New Issue
Block a user