Get unlimited public & private packages + package-based permissions with npm Pro.Get started »

cache-chunk-store

3.0.0 • Public • Published

cache-chunk-store travis npm downloads javascript style guide

In-memory LRU (least-recently-used) cache for abstract-chunk-store compliant stores

abstract chunk store

This caches the results of store.get() calls using lru-cache. See the lru-cache docs for the full list of configuration options.

Install

npm install cache-chunk-store

Usage

const CacheChunkStore = require('cache-chunk-store')
const FSChunkStore = require('fs-chunk-store') // any chunk store will work
 
const store = new CacheChunkStore(new FSChunkStore(10), {
  // options are passed through to `lru-cache`
  max: 100 // maximum cache size (this is probably the only option you need)
})
 
store.put(0, new Buffer('abc'), err => {
  if (err) throw err
 
  store.get(0, (err, data) => {
    if (err) throw err
    console.log(data)
 
    // this will be super fast because it's cached in memory!
    store.get(0, (err, data) => {
      if (err) throw err
      console.log(data)
    })
  })
})
 

License

MIT. Copyright (c) Feross Aboukhadijeh.

Install

npm i cache-chunk-store

DownloadsWeekly Downloads

283

Version

3.0.0

License

MIT

Unpacked Size

5.18 kB

Total Files

4

Last publish

Collaborators

  • avatar
  • avatar