Mycache
Mycache is a cache library enhanced front end local cache. It can provide 4 stores, includes indexedDB, localStorage, sessionStorage and memorayStore.
Installation
NPM is the easiest and fastest way to get started using Mycache.
npm install mycache
How to use Mycache
Init cache
import Mycache from 'mycache';
const mycache = new Mycache();
Sample example used the promise/async form:
import Mycache from 'mycache';
const mycache = new Mycache();
await mycache.set('key', 'value');
const val = await mycache.get('key');
Configuration
import Mycache from 'mycache';
const mycache = new Mycache({
name: 'mycache',
oldItemsCount: 0.2,
});
Mycache API:
function get(key: string): Promise<any> {}
function gets() : Promise<any> {}
function set<T>(key: string, value: T, expire: number | Date = -1): Promise<T> {}
function append<T>(key: string, value: T, expire: number | Date = -1): Promise<T> {}
function has(key: string): Promise<boolean> {}
function remove(key: string): Promise<void> {}
function keys(): Promise<string[]> {}
function clear(): Promise<void> {}
function length(): Promise<number> {}
function each(iterator: (value: any, key: string, iterationNumber: number) => void): Promise<boolean> {}
function isExpired(key: string): Promise<boolean> {}
function getExpiredKeys(): Promise<string[]> {}
function getOverLengthKeys(): Promise<string[]> {}
function getOldKeys(): Promise<string[]> {}
function getSortedItems(): Promise<typed.IMycacheMetaDataMap[]> {}
License
MIT