Lazy API
# About lazy Processing
`Thoth` has a lazy execution method for parsing and deregistration.
Delayed execution is easiest to implement with Deno Cron.
A sample is shown below.
import { createThothClient } from "jsr:@octo/thoth";
const kv = await Deno.openKv();
const thoth = createThothClient(kv, 3);
await thoth.register(["ABCDEFG", "abcdefg"], "000001", true);
Deno.cron("THOTH TASK", "* * * * *", async () => {
console.log("START: THOTH TASK");
await thoth.analysis();
await thoth.unregisterTask();
console.log("END: THOTH TASK ");
});
console.log("search");
console.log(" Keyword: ABC =>", await thoth.search("ABC"));
setInterval(async () => {
console.log("search");
console.log(" Keyword: ABC =>", await thoth.search("ABC"));
}, 5000);
Please execute the following command.
$ deno run --unstable-kv lazy.ts
search
Keyword: ABC => {}
search
Keyword: ABC => {}
START: THOTH TASK
END: THOTH TASK
search
Keyword: ABC => { "000001": { "0": [ 0 ] } }