memcache-client-memoizer
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "memcache-client-memoizer", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Memoizes promise-returning functions via memcache-client", | ||
@@ -34,4 +34,11 @@ "main": "index.js", | ||
"standard": { | ||
"globals": [ "jest", "beforeEach", "afterEach", "describe", "it", "expect" ] | ||
"globals": [ | ||
"jest", | ||
"beforeEach", | ||
"afterEach", | ||
"describe", | ||
"it", | ||
"expect" | ||
] | ||
} | ||
} |
@@ -18,6 +18,3 @@ ## memcache-client-memoizer | ||
## Note: | ||
Rejected promises and callbacks called with an `err` argument are not memoized, since that's a pretty bad idea :) | ||
## Promise Memoization | ||
## API | ||
`memoizer(options)` | ||
@@ -29,8 +26,11 @@ | ||
* `fn`: `Function`. Required. The function to memoize, must return a Promise. | ||
* `keyFn`: `(args to fn) => 'key-string'`. Required. A function which returns a string cache-key for memcached. This | ||
function is called with the same arguments as `fn`, allowing you to create a dynamic cache-key, for example: | ||
```javascript | ||
const exampleKeyFn = ({ name, color }) => `${name}:${color}` | ||
``` | ||
* `keyFn`: `(args to fn) => 'key-string'`. Required. A function which returns a string cache-key for memcached. This function is called with the same arguments as `fn`, allowing you to create a dynamic cache-key, for example: | ||
```javascript | ||
const exampleKeyFn = ({ name, color }) => `${name}:${color}` | ||
``` | ||
* `setOptions`: `object`. Optional. `memcached-client` [command options](https://www.npmjs.com/package/memcache-client#command-options). | ||
### Note: | ||
Rejected promises and callbacks called with an `err` argument are not memoized, since that's a pretty bad idea :) | ||
### Example: | ||
@@ -37,0 +37,0 @@ ```javascript |
120591