mirror of
https://git.mirrors.martin98.com/https://github.com/jina-ai/reader
synced 2025-08-14 18:15:54 +08:00
fix: setup expire for pdf caches
This commit is contained in:
parent
1ba21da0c5
commit
9c60b4b93d
@ -46,6 +46,8 @@ export class PDFExtractor extends AsyncService {
|
||||
logger = this.globalLogger.child({ service: this.constructor.name });
|
||||
pdfjs!: Awaited<typeof pPdfjs>;
|
||||
|
||||
cacheRetentionMs = 1000 * 3600 * 24 * 7;
|
||||
|
||||
constructor(
|
||||
protected globalLogger: Logger,
|
||||
protected firebaseObjectStorage: FirebaseStorageBucketControl,
|
||||
@ -278,8 +280,12 @@ export class PDFExtractor extends AsyncService {
|
||||
this.logger.warn(`Unable to extract from pdf ${url}`, { err });
|
||||
}
|
||||
|
||||
// Don't try again until the next day
|
||||
const expireMixin = extracted ? {} : { expireAt: new Date(Date.now() + 1000 * 3600 * 24) };
|
||||
// Don't try again until the next hour
|
||||
const expireMixin = extracted ? {
|
||||
expireAt: new Date(Date.now() + this.cacheRetentionMs)
|
||||
} : {
|
||||
expireAt: new Date(Date.now() + 1000 * 3600)
|
||||
};
|
||||
const theID = randomUUID();
|
||||
|
||||
await this.firebaseObjectStorage.saveFile(`pdfs/${theID}`,
|
||||
|
Loading…
x
Reference in New Issue
Block a user