{"id":44467,"library":"cache-chunk-store","title":"cache-chunk-store","description":"In-memory LRU cache for abstract-chunk-store compliant stores. Version 3.2.2 is the latest stable release, with a maintenance status and low release cadence. It wraps any abstract-chunk-store implementation (e.g., fs-chunk-store) to cache get() results using the lru package, reducing repeated I/O. Differentiators: minimal API, transparent caching, passes through options to lru (e.g., max size). Commonly used in BitTorrent clients and other peer-to-peer applications.","status":"maintenance","version":"3.2.2","language":"javascript","source_language":"en","source_url":"git://github.com/feross/cache-chunk-store","tags":["javascript","abstract-chunk-store","chunk","lru","least recently used","cache","store"],"install":[{"cmd":"npm install cache-chunk-store","lang":"bash","label":"npm"},{"cmd":"yarn add cache-chunk-store","lang":"bash","label":"yarn"},{"cmd":"pnpm add cache-chunk-store","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency - store interface must be compatible","package":"abstract-chunk-store","optional":false},{"reason":"LRU cache implementation","package":"lru","optional":false}],"imports":[{"note":"This package uses CommonJS; ESM import is not supported unless using a bundler that handles CJS interop.","wrong":"import CacheChunkStore from 'cache-chunk-store'","symbol":"CacheChunkStore","correct":"const CacheChunkStore = require('cache-chunk-store')"},{"note":"Default export only, not a named export.","wrong":"import { CacheChunkStore } from 'cache-chunk-store'","symbol":"CacheChunkStore","correct":"import CacheChunkStore from 'cache-chunk-store'"},{"note":"Destructured require works but is redundant; the default is the class itself.","wrong":"const { CacheChunkStore: MyCache } = require('cache-chunk-store')","symbol":"CacheChunkStore","correct":"const { CacheChunkStore } = require('cache-chunk-store')"}],"quickstart":{"code":"const CacheChunkStore = require('cache-chunk-store')\nconst FSChunkStore = require('fs-chunk-store')\n\nconst store = new CacheChunkStore(new FSChunkStore(10), {\n  max: 100\n})\n\nstore.put(0, Buffer.from('abc'), (err) => {\n  if (err) throw err\n  store.get(0, (err, data) => {\n    if (err) throw err\n    console.log(data.toString()) // 'abc'\n    // Cached call:\n    store.get(0, (err, data) => {\n      if (err) throw err\n      console.log(data.toString())\n    })\n  })\n})","lang":"javascript","description":"Creates a cached chunk store using fs-chunk-store with LRU max 100, puts a chunk, and retrieves it twice (second is cached)."},"warnings":[{"fix":"Ensure the inner store implements all required methods (put, get, close, destroy).","message":"The store passed to CacheChunkStore must be a valid abstract-chunk-store instance; otherwise behavior is undefined.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider using an alternative like lru-cache or wrapping manually.","message":"The lru package has been deprecated; caching behavior may not be optimal.","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Upgrade to 3.x and swap arguments: new CacheChunkStore(store, opts).","message":"In version 2.x, the constructor accepted options as first argument; in 3.x it accepts the store first.","severity":"breaking","affected_versions":">=2.0.0 <3.0.0"},{"fix":"Use Uint8Array or polyfill Buffer; or use a version that imports Buffer.","message":"Buffer is not imported; uses global Buffer which may not exist in newer Node versions (deprecated).","severity":"gotcha","affected_versions":">=3.0.0"}],"env_vars":null,"search_vec":"'3.2.2':18 'abstract':12,36,83 'abstract-chunk-stor':11,35,82 'api':58 'applic':80 'bittorr':72 'cach':2,9,46,60,91 'cache-chunk-stor':1 'cadenc':31 'chunk':3,13,37,43,84,86 'client':73 'common':69 'compliant':15 'differenti':56 'e.g':40,66 'fs':42 'fs-chunk-stor':41 'get':47 'i/o':55 'implement':39 'in-memori':5 'javascript':81 'latest':21 'least':88 'low':29 'lru':8,51,65,87 'mainten':26 'max':67 'memori':7 'minim':57 'option':63 'packag':52 'pass':61 'peer':77,79 'peer-to-p':76 'recent':89 'reduc':53 'releas':23,30 'repeat':54 'result':48 'size':68 'stabl':22 'status':27 'store':4,14,16,38,44,85,92 'transpar':59 'use':49,70,90 'version':17 'wrap':33","created_at":"2026-06-07T12:50:16.865096+00:00","updated_at":"2026-06-07T12:50:16.865096+00:00","problems":[{"fix":"Ensure the store implements get, put, close, and destroy methods.","cause":"Passed a store that is not abstract-chunk-store compliant.","error":"TypeError: store.get is not a function"},{"fix":"Use Buffer.from() to pass buffers.","cause":"Passed a non-Buffer value to put() (e.g., a number).","error":"Error: The first argument must be a string, Buffer, ArrayBuffer, Array, or array-like object."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/feross/cache-chunk-store","github":"git://github.com/feross/cache-chunk-store","docs":null,"changelog":null,"pypi":null,"npm":"cache-chunk-store","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}