import engine from 'store/src/store-engine'; import localStorage from 'store/storages/localStorage'; import expire from 'store/plugins/expire'; import init from '@utils/instance'; const storeInstance = init(); class Store { store: any; constructor() { const instance = storeInstance(); if (instance) return instance; const storages = [localStorage]; const plugins = [expire]; this.store = engine.createStore(storages, plugins); storeInstance(this); } expireGet = (key: any) => { if (this.store.getExpiration(key) > new Date().getTime()) { return this.get(key); } return null; }; expireSet = (key: any, value: any, ttl: any) => { this.store.set(key, value, ttl); }; get = (key: any) => { return this.store.get(key); }; set = (key: any, value: any) => { this.store.set(key, value); }; remove = (key: any) => { this.store.remove(key); }; } export default new Store();