# memorize-promise **Repository Path**: mirrors_floatdrop/memorize-promise ## Basic Information - **Project Name**: memorize-promise - **Description**: Cache promise result and update from time to time - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-24 - **Last Updated**: 2026-07-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # memorize-promise [![Build Status](https://travis-ci.org/floatdrop/memorize-promise.svg?branch=master)](https://travis-ci.org/floatdrop/memorize-promise) Save promise result and update it from time to time. ## Install ``` $ npm install --save memorize-promise ``` ## Usage ```js const got = require('got'); const memorizePromise = require('memorize-promise'); const cache = memorizePromise(() => got('google.com')); cache.then(res => console.log(res.body)); // Content 1 cache.then(res => console.log(res.body)); // Content 1 setTimeout(function () { cache.then(res => console.log(res.body)); // Content 2 cache.then(res => console.log(res.body)); // Content 2 cache.stop(); // Stops updates }, 5005); ``` ## API ### memorizePromise(func, [options]) #### func Type: `Function` Factory of promises. It will be called for new promise with data every `updateInterval` milliseconds. #### options ##### updateInterval Type: `Number` Default: `5000` Update interval in milliseconds. ##### ttl Type: `Number` Default: `60000` Lifetime of update timeout after last hit. ## License MIT © [Vsevolod Strukchinsky](http://github.com/floatdrop)