Reduced cache interval for print and offline bundles on feature branches.

Cache interval for print and offline bundles remains at 20 minutes for master branch. New shorter 20 second cache interval introduced for feature branches to improve developer experience.
This commit is contained in:
David Russell 2016-09-29 17:04:27 +07:00
parent b294a7c46c
commit b212f66686
2 changed files with 24 additions and 5 deletions

View File

@ -70,14 +70,30 @@ public class CacheTimeout {
}
}
/*
* Return cache timeout in milliseconds for print PDF file.
*/
public long pdf(PitchParams pp) {
return pp.isMaster() ? PDF_CACHE_MAX_AGE_MASTER : PDF_CACHE_MAX_AGE_BRANCH;
}
/*
* Return cache timeout in milliseconds for offline ZIP file.
*/
public long zip(PitchParams pp) {
return pp.isMaster() ? ZIP_CACHE_MAX_AGE_MASTER : ZIP_CACHE_MAX_AGE_BRANCH;
}
/*
* PDF generation cache timeouts (ms) for PITCHME.pdf.
*/
public static final int PDF_CACHE_MAX_AGE = 60 * 1000 * 20;
public static final long PDF_CACHE_MAX_AGE_MASTER = 60 * 1000 * 20;
public static final long PDF_CACHE_MAX_AGE_BRANCH = 20 * 1000;
/*
* Offline generation cache timeouts (ms) for PITCHME.zip.
*/
public static final int ZIP_CACHE_MAX_AGE = 60 * 1000 * 20;
public static final long ZIP_CACHE_MAX_AGE_MASTER = 60 * 1000 * 20;
public static final long ZIP_CACHE_MAX_AGE_BRANCH = 20 * 1000;
/*
* Long Lived cache timeouts (sec) for GitPitch-owned repos.
*/

View File

@ -191,7 +191,10 @@ public class PitchService {
File pdfFile = diskService.asFile(pp, PITCHME_PDF);
long pdfAge = System.currentTimeMillis() - pdfFile.lastModified();
if (pdfAge > cacheTimeout.PDF_CACHE_MAX_AGE) {
log.debug("cachedPDF: pdfAge={}, max={}, file={}",
pdfAge, cacheTimeout.pdf(pp), pdfFile);
if (pdfAge > cacheTimeout.pdf(pp)) {
diskService.delete(pp, PITCHME_PDF);
}
@ -235,9 +238,9 @@ public class PitchService {
long zipAge = System.currentTimeMillis() - zipFile.lastModified();
log.debug("cachedZip: zipAge={}, max={}, file={}",
zipAge, cacheTimeout.ZIP_CACHE_MAX_AGE, zipFile);
zipAge, cacheTimeout.zip(pp), zipFile);
if (zipAge > cacheTimeout.ZIP_CACHE_MAX_AGE) {
if (zipAge > cacheTimeout.zip(pp)) {
diskService.delete(pp, PITCHME_ZIP);
diskService.deepDelete(pp, PITCHME_ZIP_DIR);
log.debug("cachedZip: deleted expired zip artifacts.");