functional-memoize v2.0.2
functional-memoize
Functional Memoize is a package to implement an approach of a generic memoization of functions from a functional programming point of view.
functional-memoize.cacheWrapper(findInCache, saveInCache, memoizeConfigOptions, functionToMemoize) ⇒ function
Curriable function to wrapp the function to be memoized with a provided cache strategy.
Kind: static method of functional-memoize
Returns: function - - Function that wrapp the functionToMemoize with the strategy of cache.
This function is always async, return a Promise. The returned function has an atribute force, this force atribute is a function
that force the use of the functionToMemoize and saveit in the cache.
Param | Type | Description |
---|---|---|
findInCache | function | Function to find in the cache implemented. |
saveInCache | function | Function to save in the cache implemented. |
memoizeConfigOptions | object | Object to configure the cahe options. |
memoizeConfigOptions.ttl | number | Time to live for the memoization by default is 1. |
memoizeConfigOptions.ttlMeasure | string | Measure of the time to live, ir use the same as moment (miliseconds, seconds, minutes, hours, days ...) by default is days. |
memoizeConfigOptions.functionName | string | The Implementation consider a unique cached. |
functionToMemoize | function | Function to be memoized by the cache wrapper. |
functional-memoize.inMemoryCacheWrapper(memoizeConfigOptions, functionToMemoize) ⇒ function
Curriable function to wrapp the function to be memoized with a in Memory cache strategy.
Kind: static method of functional-memoize
Returns: function - - Function that wrapp the functionToMemoize with the strategy of cache.
This function is always async, return a Promise. The returned function has an atribute force, this force atribute is a function
that force the use of the functionToMemoize and saveit in the cache.
Param | Type | Description |
---|---|---|
memoizeConfigOptions | object | Object to configure the cahe options. |
memoizeConfigOptions.ttl | number | Time to live for the memoization by default is 1. |
memoizeConfigOptions.ttlMeasure | string | Measure of the time to live, ir use the same as moment (miliseconds, seconds, minutes, hours, days ...) by default is days. |
memoizeConfigOptions.functionName | string | The Implementation consider a unique cached. |
functionToMemoize | function | Function to be memoized by the cache wrapper. |
functional-memoize.inMongoCacheWrapper(mongoDBConfig, memoizeConfigOptions, functionToMemoize) ⇒ function
Curriable function to wrapp the function to be memoized with a mongodb cache strategy.
Kind: static method of functional-memoize
Returns: function - - Function that wrapp the functionToMemoize with the strategy of cache.
This function is always async, return a Promise. The returned function has an atribute force, this force atribute is a function
that force the use of the functionToMemoize and saveit in the cache.
Param | Type | Description |
---|---|---|
mongoDBConfig | Object | MongoDB configuration options. |
mongoDBConfig.mongodbUri | String | mongoDB connection string. |
mongoDBConfig.mongodbCacheCollection | String | Name of the mongoDB collection. |
memoizeConfigOptions | Object | Object to configure the cahe options. |
memoizeConfigOptions.ttl | Number | Time to live for the memoization by default is 1. |
memoizeConfigOptions.ttlMeasure | String | Measure of the time to live, ir use the same as moment (miliseconds, seconds, minutes, hours, days ...) by default is days. |
memoizeConfigOptions.functionName | String | The Implementation consider a unique cached. |
functionToMemoize | function | Function to be memoized by the cache wrapper. |