Skip to content

Commit

Permalink
#1771: clear transactionalEmail cache to trigger re-caching after pub…
Browse files Browse the repository at this point in the history
…lish
  • Loading branch information
JoernBerkefeld committed Jan 10, 2025
1 parent 50b923f commit a0958bb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion @types/lib/metadataTypes/Journey.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion @types/lib/util/cache.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion @types/lib/util/cache.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions lib/metadataTypes/Journey.js
Original file line number Diff line number Diff line change
Expand Up @@ -2110,6 +2110,9 @@ class Journey extends MetadataType {
if (transactionalKeyArr.length) {
executedKeyArr.push(...transactionalKeyArr);

// reset transactionalEmail cache to trigger re-caching it.
cache.clearCache(this.buObject.mid, 'transactionalEmail');

Util.logger.info('Retrieving relevant journeys');
const retriever = new Retriever(this.properties, this.buObject);

Expand Down
11 changes: 8 additions & 3 deletions lib/util/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,17 @@ export default {
/**
* clean cache for one BU if mid provided, otherwise whole cache
*
* @param {number} [mid] of business unit
* @param {number} [mid] limit clearing to provided business unit MID
* @param {string} [type] optionally limit clearing to specific metadata type; only used if mid is provided
* @returns {void}
*/
clearCache: (mid) =>
clearCache: (mid, type) =>
mid
? Object.keys(dataStore[mid]).forEach((key) => delete dataStore[mid][key])
? Object.keys(dataStore[mid]).forEach((key) => {
if (!type || type === key) {
delete dataStore[mid][key];
}
})
: Object.keys(dataStore).forEach((key) => delete dataStore[key]),
/* eslint-enable unicorn/no-array-for-each */

Expand Down

0 comments on commit a0958bb

Please sign in to comment.