* use import_map.json instead of per-file import * remove test_deps.ts in favor of import_map * remove common/deps.ts in favor of import_map * use import_map instead of server/deps.ts * make all plug-api files usable without an import_map * make all lib files usable without an import_map * remove web/deps.ts in favor of import_map * fix plug build * remove plug-api/deps.ts in favor of lib/deps.ts * fix server deps bundled in client deps
18 lines
522 B
TypeScript
18 lines
522 B
TypeScript
import { ttlCache } from "$lib/memory_cache.ts";
|
|
import { sleep } from "$lib/async.ts";
|
|
import { assertEquals } from "$std/testing/asserts.ts";
|
|
|
|
Deno.test("Memory cache", async () => {
|
|
let calls = 0;
|
|
async function expensiveFunction(key: string) {
|
|
calls++;
|
|
await sleep(1);
|
|
return key;
|
|
}
|
|
assertEquals("key", await ttlCache("key", expensiveFunction, 0.01));
|
|
assertEquals(1, calls);
|
|
assertEquals("key", await ttlCache("key", expensiveFunction, 0.01));
|
|
assertEquals(1, calls);
|
|
await sleep(10);
|
|
});
|