Ghost/ghost/custom-theme-settings-service/lib/cache.js
Kevin Ansfield c4f364996b Removed model dependency in custom theme settings cache
refs https://github.com/TryGhost/Team/issues/1070

- having a dependency on a model in the cache service meant that Ghost had to know about that and pre-initialize the cache during boot, even though that didn't actually do anything except create a cache instance
- by making the cache a simple key/value store able to be populated from the cache settings service when a theme is activated it means that Ghost doesn't need to perform any extra initialization when the cache is initialized via `require`
2021-09-23 09:16:59 +01:00

20 lines
368 B
JavaScript

module.exports = class CustomThemeSettingsCache {
constructor() {
this.content = new Object();
}
get(key) {
return this.content[key].value;
}
getAll() {
return this.content;
}
populate(settings) {
settings.forEach((setting) => {
this.content[setting.key] = setting.value;
});
}
};