{"_id":"p-cache","_rev":"5-1cdfa070f267a0550ec063ecf1add09c","name":"p-cache","description":"Async function wrapper to cache results via lru-cache","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"p-cache","version":"1.0.0","description":"Async function wrapper to cache results via lru-cache","main":"index.js","repository":{"type":"git","url":"git+https://github.com/fisch0920/p-cache.git"},"author":{"name":"Travis Fischer"},"license":"MIT","scripts":{"test":"standard && ava -v"},"dependencies":{"lru-cache":"^4.1.1","object-hash":"^1.1.8"},"devDependencies":{"ava":"^0.19.1","sinon":"^2.4.1","standard":"^10.0.2"},"gitHead":"3d5c43ee9af5fd26591adea3025d15c6d4cc8b70","bugs":{"url":"https://github.com/fisch0920/p-cache/issues"},"homepage":"https://github.com/fisch0920/p-cache#readme","_id":"p-cache@1.0.0","_npmVersion":"5.0.3","_nodeVersion":"8.1.4","_npmUser":{"name":"fisch0920","email":"fisch0920@gmail.com"},"dist":{"integrity":"sha512-PnaJdspYOnRLV9adX6kGtGCS5k1+wrcoZ2SZ6HPawytI46vAd4brDN3iV0wE0S1hvFoFzJRD6mLDuaG1OtQZ4g==","shasum":"1598ff8523ccd8d71ba63909a2d1b3d9cad94ef7","tarball":"https://registry.npmjs.org/p-cache/-/p-cache-1.0.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDsmeZLUs6w2PENfENfVzg+EoKqJj/aFI9xqsssXyDAbAIhAMctxGn1NIymgV5XCDBN4C1KXi2MLL+hwHnzfm0zencX"}]},"maintainers":[{"name":"fisch0920","email":"fisch0920@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-cache-1.0.0.tgz_1501199259259_0.2591920457780361"},"directories":{}},"1.0.1":{"name":"p-cache","version":"1.0.1","description":"Async function wrapper to cache results via lru-cache","main":"index.js","repository":{"type":"git","url":"https://github.com/fisch0920/p-cache.git"},"author":{"name":"Travis Fischer"},"license":"MIT","scripts":{"test":"standard && ava -v"},"engines":{"node":">=8"},"dependencies":{"lru-cache":"^4.1.1","object-hash":"^1.1.8"},"devDependencies":{"ava":"^0.19.1","sinon":"^2.4.1","standard":"^10.0.2"},"_id":"p-cache@1.0.1","dist":{"shasum":"a132c84a232915067fb0dd8fa155a9e17b2ef99a","tarball":"https://registry.npmjs.org/p-cache/-/p-cache-1.0.1.tgz","fileCount":6,"unpackedSize":4193,"integrity":"sha512-vdwcMvhOCA/a+evc/cMAedMpLrMN32eZY/9pIZkyRu5Qeqp84mkTo4TO3pSuguRle3UW5JG+OGJHNmat1lVbxA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDznXZrINjc+pTmwgMM6fQRDvArM3v1OdO1p7piFEQFSQIhAL5kE4dlWLAd+9zr+giWK2wZbqXEyotXsorn5eVoCQeh"}]},"maintainers":[{"name":"fisch0920","email":"fisch0920@gmail.com"}],"_npmUser":{"name":"fisch0920","email":"fisch0920@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-cache_1.0.1_1521038098998_0.7228932870805644"},"_hasShrinkwrap":false}},"readme":"# p-cache\n\n> Decorator to memoize the results of async functions via lru-cache.\n\n[![NPM](https://img.shields.io/npm/v/p-cache.svg)](https://www.npmjs.com/package/p-cache) [![Build Status](https://travis-ci.org/transitive-bullshit/p-cache.svg?branch=master)](https://travis-ci.org/transitive-bullshit/p-cache) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n## Features\n\n- Uses [lru-cache](https://www.npmjs.com/package/lru-cache) for caching impl\n- Uses [object-hash](https://www.npmjs.com/package/hash-object) for implicit cache key derivation from function args\n- Thoroughly tested in production\n\n## Install\n\n```bash\nnpm install --save p-cache\n```\n\n## Usage\n\n```js\nconst request = require('request-promise-native')\n\nconst pCache = require('p-cache')({\n  label: 'test-service',\n  // pass args to lru-cache here\n  max: 1000\n})\n\n// returns an async function which gets the given url, with the results being \n// cached via lru-cache up to 1000 urls\nmodule.exports = pCache(async (url) => {\n  return request(url)\n})\n```\n\n## API\n\n### function pCache(opts)\n\nReturns a function decorator that will wrap calls to the target function in an lru-cache instance defined by these `opts`.\n\n- `opts` - object, optional\n- `opts.label` - string, optional label to use for displaying cache hits and misses\n- `opts.log` - function, optional function to use for displaying cache hits and misses (default: `console.log`)\n\n*Note* all unrecognized options are passed onto [lru-cache](https://github.com/isaacs/node-lru-cache)\n- `opts.max` - number, optional passed onto [lru-cache](https://github.com/isaacs/node-lru-cache)\n- `opts.maxAge` - number, optional passed onto [lru-cache](https://github.com/isaacs/node-lru-cache)\n- `opts.length` - function, optional passed onto [lru-cache](https://github.com/isaacs/node-lru-cache)\n- `opts.dispose` - function, optional passed onto [lru-cache](https://github.com/isaacs/node-lru-cache)\n- `opts.stale` - boolean, optional passed onto [lru-cache](https://github.com/isaacs/node-lru-cache)\n- `opts.noDisposeOnSet` - boolean, optional passed onto [lru-cache](https://github.com/isaacs/node-lru-cache)\n\n`pCache(opts) => Function<Promise>(async function(...args))`\n\n## License\n\nMIT © [Travis Fischer](https://github.com/fisch0920)\n","maintainers":[{"name":"fisch0920","email":"fisch0920@gmail.com"}],"time":{"modified":"2022-06-23T05:42:42.715Z","created":"2017-07-27T23:47:39.327Z","1.0.0":"2017-07-27T23:47:39.327Z","1.0.1":"2018-03-14T14:34:59.121Z"},"repository":{"type":"git","url":"https://github.com/fisch0920/p-cache.git"},"author":{"name":"Travis Fischer"},"license":"MIT","readmeFilename":"README.md"}