mirror of
https://git.mirrors.martin98.com/https://github.com/jina-ai/reader
synced 2025-08-17 10:05:56 +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 });
|
logger = this.globalLogger.child({ service: this.constructor.name });
|
||||||
pdfjs!: Awaited<typeof pPdfjs>;
|
pdfjs!: Awaited<typeof pPdfjs>;
|
||||||
|
|
||||||
|
cacheRetentionMs = 1000 * 3600 * 24 * 7;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected globalLogger: Logger,
|
protected globalLogger: Logger,
|
||||||
protected firebaseObjectStorage: FirebaseStorageBucketControl,
|
protected firebaseObjectStorage: FirebaseStorageBucketControl,
|
||||||
@ -278,8 +280,12 @@ export class PDFExtractor extends AsyncService {
|
|||||||
this.logger.warn(`Unable to extract from pdf ${url}`, { err });
|
this.logger.warn(`Unable to extract from pdf ${url}`, { err });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't try again until the next day
|
// Don't try again until the next hour
|
||||||
const expireMixin = extracted ? {} : { expireAt: new Date(Date.now() + 1000 * 3600 * 24) };
|
const expireMixin = extracted ? {
|
||||||
|
expireAt: new Date(Date.now() + this.cacheRetentionMs)
|
||||||
|
} : {
|
||||||
|
expireAt: new Date(Date.now() + 1000 * 3600)
|
||||||
|
};
|
||||||
const theID = randomUUID();
|
const theID = randomUUID();
|
||||||
|
|
||||||
await this.firebaseObjectStorage.saveFile(`pdfs/${theID}`,
|
await this.firebaseObjectStorage.saveFile(`pdfs/${theID}`,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user