1. cache-chunk-store
In-memory LRU cache for abstract-chunk-store compliant stores
cache-chunk-store
Package: cache-chunk-store
Created by: feross
Last modified: Mon, 13 Jun 2022 05:23:09 GMT
Version: 3.2.2
License: MIT
Downloads: 11,380
Repository: https://github.com/feross/cache-chunk-store

Install

npm install cache-chunk-store
yarn add cache-chunk-store

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.

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code