mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-19 08:31:43 +03:00
fb3cbe5fc8
fixes https://github.com/TryGhost/Team/issues/2522 When sending an email for multiple batches at the same time, we now reuse the same email body for each batch in the same segment. This reduces the amount of database queries and makes the sending more reliable in case of database failures. The cache is short lived. After sending the email it is automatically garbage collected.
21 lines
594 B
JavaScript
21 lines
594 B
JavaScript
/**
|
|
* This is a cache provider that lives very short in memory, there is no need for persistence.
|
|
* It is created when scheduling an email in the batch sending service, and is then passed to the sending service. The sending service
|
|
* can optionally use a passed cache provider to reuse the email body for each batch with the same segment.
|
|
*/
|
|
class EmailBodyCache {
|
|
constructor() {
|
|
this.cache = new Map();
|
|
}
|
|
|
|
get(key) {
|
|
return this.cache.get(key) ?? null;
|
|
}
|
|
|
|
set(key, value) {
|
|
this.cache.set(key, value);
|
|
}
|
|
}
|
|
|
|
module.exports = EmailBodyCache;
|