22 lines
647 B
TypeScript
22 lines
647 B
TypeScript
|
|
import { ExtractedArticle } from "./extract";
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 本次会话已经抓过的全文。
|
|||
|
|
*
|
|||
|
|
* 只放内存:抓一次读多次够用,也避免把几十万字写进 data.json。
|
|||
|
|
* 关掉 Obsidian 就没了,下次点同一篇会重新抓(想要长期留存用「保存为笔记」)。
|
|||
|
|
*/
|
|||
|
|
const cache = new Map<number, ExtractedArticle>();
|
|||
|
|
|
|||
|
|
export function getCached(feedId: number): ExtractedArticle | undefined {
|
|||
|
|
return cache.get(feedId);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
export function setCached(feedId: number, article: ExtractedArticle): void {
|
|||
|
|
cache.set(feedId, article);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
export function hasCached(feedId: number): boolean {
|
|||
|
|
return cache.has(feedId);
|
|||
|
|
}
|