Cache Facade
Browser Cache inspired by Laravel's cache::remember
. You can reduce API call with fluent syntax.
Installation
yarn add cache-facade
Usage
async someAsyncFunction
In the above example, cache.remember
will look for saved cache first. Then, if cache found then return it. Else the third function's result will be passed. If over 30 minutes passed since the cache saved, Cache Facade will run the third function and save it.
Syntax
cache.remember
cache.rememberkeyName: string, expiredTimeInMinutes: number, otherwise:Promise<any>
cache.setDriver
Set storage driver. Default is localStorage
.
cache.setDriverDriver.memorycache.setDriverDriver.localStorage
TODO
- React Native support. Add
AsyncStorage
Driver. - Custom driver support.