blob: 15355ba01c3225d33521b3ae85a411131f468aa5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
import MemoryStorage from '../infrastructures/MemoryStorage';
const CACHED_SETTING_KEY = 'setting';
export default class SettingRepository {
private cache: MemoryStorage;
constructor() {
this.cache = new MemoryStorage();
}
get(): Promise<any> {
return Promise.resolve(this.cache.get(CACHED_SETTING_KEY));
}
update(value: any): any {
return this.cache.set(CACHED_SETTING_KEY, value);
}
async setProperty(name: string, value: string): Promise<any> {
let current = await this.get();
current.properties[name] = value;
return this.update(current);
}
}
|