Add cache pinning and health controls
This commit is contained in:
@@ -271,6 +271,21 @@ describe('media cache jobs', () => {
|
||||
expect(await cache.getReady('lruAAAAAAA3')).not.toBeNull();
|
||||
});
|
||||
|
||||
test('pinned copies are skipped while automatic LRU eviction selects another row', async () => {
|
||||
await clearDb();
|
||||
const size = readFileSync(fx('good.mp4')).length;
|
||||
const { cache } = makeCache({ maxBytes: size * 2 + 60 * 250 * 1024 + 50_000, duration: 10 });
|
||||
await cache.init();
|
||||
await cache.ensureCached('pinAAAAAA01', { priority: HIGH });
|
||||
await cache.ensureCached('pinAAAAAA02', { priority: HIGH });
|
||||
await dbmod.upsertMedia('pinAAAAAA01', { last_access: 1000, pinned: 1 });
|
||||
await dbmod.upsertMedia('pinAAAAAA02', { last_access: 2000 });
|
||||
await cache.ensureCached('pinAAAAAA03', { priority: HIGH });
|
||||
expect((await dbmod.getMedia('pinAAAAAA01')).pinned).toBe(1);
|
||||
expect(await dbmod.getMedia('pinAAAAAA02')).toBeNull();
|
||||
expect(await cache.getReady('pinAAAAAA03')).not.toBeNull();
|
||||
});
|
||||
|
||||
test('eviction follows listMediaEvictionOrder when the db provides it', async () => {
|
||||
await clearDb();
|
||||
const size = readFileSync(fx('good.mp4')).length;
|
||||
|
||||
Reference in New Issue
Block a user