{"_id":"hypercore-cache","_rev":"480984","name":"hypercore-cache","description":"A caching module for Hypercore tree nodes and blocks ","dist-tags":{"latest":"1.0.2"},"maintainers":[{"name":"andrewosh","email":"andrewosh@gmail.com"}],"time":{"modified":"2021-08-05T09:36:58.000Z","created":"2020-02-03T14:55:04.850Z","1.0.2":"2020-02-03T16:36:13.902Z","1.0.1":"2020-02-03T14:55:50.364Z","1.0.0":"2020-02-03T14:55:04.850Z"},"users":{},"author":{"name":"Andrew Osheroff","email":"andrewosh@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/andrewosh/hypercore-cache.git"},"versions":{"1.0.2":{"name":"hypercore-cache","version":"1.0.2","description":"A caching module for Hypercore tree nodes and blocks ","main":"index.js","scripts":{"test":"standard && tape test/*.js"},"repository":{"type":"git","url":"git+https://github.com/andrewosh/hypercore-cache.git"},"keywords":["hypercore","cache"],"author":{"name":"Andrew Osheroff","email":"andrewosh@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/andrewosh/hypercore-cache/issues"},"homepage":"https://github.com/andrewosh/hypercore-cache#readme","devDependencies":{"standard":"^14.3.1","tape":"^4.13.0"},"gitHead":"e8c1bb353e04a126bf414291ff44eef6e1052be3","_id":"hypercore-cache@1.0.2","_nodeVersion":"12.13.1","_npmVersion":"6.12.1","dist":{"shasum":"f170a5fda597437533e1563f39dd60dbbd56056d","size":3650,"noattachment":false,"key":"/hypercore-cache/-/hypercore-cache-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/hypercore-cache/download/hypercore-cache-1.0.2.tgz"},"maintainers":[{"name":"andrewosh","email":"andrewosh@gmail.com"}],"_npmUser":{"name":"andrewosh","email":"andrewosh@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hypercore-cache_1.0.2_1580747773790_0.8909643283715849"},"_hasShrinkwrap":false,"publish_time":1580747773902,"_cnpm_publish_time":1580747773902},"1.0.1":{"name":"hypercore-cache","version":"1.0.1","description":"A caching module for Hypercore tree nodes and blocks ","main":"index.js","scripts":{"test":"standard && tape test/*.js"},"repository":{"type":"git","url":"git+https://github.com/andrewosh/hypercore-cache.git"},"keywords":["hypercore","cache"],"author":{"name":"Andrew Osheroff","email":"andrewosh@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/andrewosh/hypercore-cache/issues"},"homepage":"https://github.com/andrewosh/hypercore-cache#readme","devDependencies":{"standard":"^14.3.1","tape":"^4.13.0"},"gitHead":"04d6759ecc8919dc3b1d1380fed5c4468021a350","_id":"hypercore-cache@1.0.1","_nodeVersion":"12.13.1","_npmVersion":"6.12.1","dist":{"shasum":"4537836b95ddd30bc23d77c243dcadce34c46466","size":3653,"noattachment":false,"key":"/hypercore-cache/-/hypercore-cache-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/hypercore-cache/download/hypercore-cache-1.0.1.tgz"},"maintainers":[{"name":"andrewosh","email":"andrewosh@gmail.com"}],"_npmUser":{"name":"andrewosh","email":"andrewosh@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hypercore-cache_1.0.1_1580741750268_0.4554059300946087"},"_hasShrinkwrap":false,"publish_time":1580741750364,"_cnpm_publish_time":1580741750364},"1.0.0":{"name":"hypercore-cache","version":"1.0.0","description":"A caching module for Hypercore tree nodes and blocks ","main":"index.js","scripts":{"test":"standard && tape test/*.js"},"repository":{"type":"git","url":"git+https://github.com/andrewosh/hypercore-cache.git"},"keywords":["hypercore","cache"],"author":{"name":"Andrew Osheroff","email":"andrewosh@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/andrewosh/hypercore-cache/issues"},"homepage":"https://github.com/andrewosh/hypercore-cache#readme","devDependencies":{"standard":"^14.3.1","tape":"^4.13.0"},"gitHead":"82d1f56bf8209dba18c197f206a548a94b55faf6","_id":"hypercore-cache@1.0.0","_nodeVersion":"12.13.1","_npmVersion":"6.12.1","dist":{"shasum":"759968aaa69cfb03f92bacbed2eff5bec18bad97","size":3653,"noattachment":false,"key":"/hypercore-cache/-/hypercore-cache-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/hypercore-cache/download/hypercore-cache-1.0.0.tgz"},"maintainers":[{"name":"andrewosh","email":"andrewosh@gmail.com"}],"_npmUser":{"name":"andrewosh","email":"andrewosh@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hypercore-cache_1.0.0_1580741704669_0.28426827861975323"},"_hasShrinkwrap":false,"publish_time":1580741704850,"_cnpm_publish_time":1580741704850}},"readme":"# hypercore-cache\n[![Build Status](https://travis-ci.com/andrewosh/hypercore-cache.svg?token=WgJmQm3Kc6qzq1pzYrkx&branch=master)](https://travis-ci.com/andrewosh/hypercore-cache)\n\nA caching module for Hypercore tree nodes and blocks.\n\nThis module mplements the [hashlru](https://github.com/dominictarr/hashlru) algorithm internally for LRU caching, but it uses byte length estimates instead of the entry count for eviction.\n\n### Installation\n```\nnpm i hypercore-cache --save\n```\n\n### API\n\n#### `const cache = new HypercoreCache(opts = {})`\nCreates a new cache.\n\nOptions can include:\n```js\n{\n  maxByteSize: 1e6,  // The soft maximum size of the cache (actual max size can go up to 2x this value).\n  estimateSize: val => { ... },  // A function from a value to its size estimate.\n  onEvict: (evicted) => { ... }  // A hook that's called when stale entries (a Map) have been evicted.\n}\n```\n\n#### `cache.set(key, value)`\nSets `key` to `value`.\n\n#### `cache.get(key)`\nGets the value for `key`.\n\n#### `cache.del(key)`\nDeletes `key` from the cache.\n\n#### `const subCache = cache.namespace()`\nCreates a namespaced sub-cache which mirrors the hypercore-cache API.\n\nThis is useful if you want to create a single cache instance that manages resources for multiple hypercores.\n\n### License\nMIT\n","_attachments":{},"homepage":"https://github.com/andrewosh/hypercore-cache#readme","bugs":{"url":"https://github.com/andrewosh/hypercore-cache/issues"},"license":"MIT"}