Skip to content

Commit

Permalink
invalidate cache per generation (project-chip#966)
Browse files Browse the repository at this point in the history
when a user changes configurations, such change might have invalidated some configuration specific setting that has been cached already. By flushing the cache, it enables us to cache SQL results without disregarding user inputs.
  • Loading branch information
Jing T authored Mar 10, 2023
1 parent 2dec018 commit f630679
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src-electron/generator/generation-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const dbEnum = require('../../src-shared/db-enum.js')
const env = require('../util/env')
const templateEngine = require('./template-engine.js')
const dbApi = require('../db/db-api.js')
const dbCache = require('../db/db-cache.js')
const e = require('express')

/**
Expand Down Expand Up @@ -828,6 +829,9 @@ async function generateAndWriteFiles(
generationLog: null,
}
) {
// in case user customization has invalidated the cache
dbCache.clear()

let timing = {}
if (options.fileLoadTime) {
timing.fileLoad = {
Expand Down Expand Up @@ -1066,6 +1070,9 @@ async function contentIndexer(content, linesPerIndex = 2000) {
* @returns promise that resolves into a preview object.
*/
async function generateSingleFileForPreview(db, sessionId, outFileName) {
// in case user customization has invalidated the cache
dbCache.clear()

return queryPackage
.getSessionPackagesByType(
db,
Expand Down

0 comments on commit f630679

Please sign in to comment.