Socket
Socket
Sign inDemoInstall

cache-chunk-store

Package Overview
Dependencies
3
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cache-chunk-store

In-memory LRU cache for abstract-chunk-store compliant stores


Version published
Maintainers
2
Install size
33.1 kB
Created

Readme

Source

cache-chunk-store ci 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. See the lru 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.

Keywords

FAQs

Last updated on 19 May 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc