This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
outline/app/stores/CacheStore.js
2018-03-26 22:18:53 -07:00

30 lines
603 B
JavaScript

// @flow
import localForage from 'localforage';
class CacheStore {
key: string;
version: number = 2;
cacheKey = (key: string): string => {
return `CACHE_${this.key}_${this.version}_${key}`;
};
getItem = (key: string): any => {
return localForage.getItem(this.cacheKey(key));
};
setItem = (key: string, value: any): any => {
return localForage.setItem(this.cacheKey(key), value);
};
removeItem = (key: string) => {
return localForage.removeItem(this.cacheKey(key));
};
constructor(cacheKey: string) {
this.key = cacheKey;
}
}
export default CacheStore;