memo-json
A memoization decorator caching JSON results to disk. Speed up development applications depending on external resources.
Install package
yarn add memo-json
Usage
import {memo} from 'memo'
const getDataMemo = memo(function getData(param: string) { ... })
await getDataMemo('a')
await getDataMemo('a')
await getDataMemo('b')
The first run of the above code will generate cache like below being reused in the subsequent calls.
# ${process.env.cwd()}/${functionName}-${paramHash}.json
.memo/getRemoteData-4e6c99.json
.memo/getRemoteData-dee827.json
Debug
Debug logs are available when you have DEBUG
environment.
DEBUG=memo-json ts-node your-script.ts
Options
dir
- Optional, ".memo"
by default. ex. @memo({ dir: '__generated__' })
enable
- Optional, true
by default. ex. @memo({ enable: process.env.NODE_ENV !== 'production' })
CLI
memo clean
License
Apache 2.0
Author
Soichi Takamura @piglovesyou