nomagick commited on
Commit
9c60b4b
·
unverified ·
1 Parent(s): 1ba21da

fix: setup expire for pdf caches

Browse files
backend/functions/src/services/pdf-extract.ts CHANGED
@@ -46,6 +46,8 @@ export class PDFExtractor extends AsyncService {
46
  logger = this.globalLogger.child({ service: this.constructor.name });
47
  pdfjs!: Awaited<typeof pPdfjs>;
48
 
 
 
49
  constructor(
50
  protected globalLogger: Logger,
51
  protected firebaseObjectStorage: FirebaseStorageBucketControl,
@@ -278,8 +280,12 @@ export class PDFExtractor extends AsyncService {
278
  this.logger.warn(`Unable to extract from pdf ${url}`, { err });
279
  }
280
 
281
- // Don't try again until the next day
282
- const expireMixin = extracted ? {} : { expireAt: new Date(Date.now() + 1000 * 3600 * 24) };
 
 
 
 
283
  const theID = randomUUID();
284
 
285
  await this.firebaseObjectStorage.saveFile(`pdfs/${theID}`,
 
46
  logger = this.globalLogger.child({ service: this.constructor.name });
47
  pdfjs!: Awaited<typeof pPdfjs>;
48
 
49
+ cacheRetentionMs = 1000 * 3600 * 24 * 7;
50
+
51
  constructor(
52
  protected globalLogger: Logger,
53
  protected firebaseObjectStorage: FirebaseStorageBucketControl,
 
280
  this.logger.warn(`Unable to extract from pdf ${url}`, { err });
281
  }
282
 
283
+ // Don't try again until the next hour
284
+ const expireMixin = extracted ? {
285
+ expireAt: new Date(Date.now() + this.cacheRetentionMs)
286
+ } : {
287
+ expireAt: new Date(Date.now() + 1000 * 3600)
288
+ };
289
  const theID = randomUUID();
290
 
291
  await this.firebaseObjectStorage.saveFile(`pdfs/${theID}`,