Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@prrashi/lru-diskcache

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prrashi/lru-diskcache

A disk cache object that deletes the least-recently-used items.

  • 1.1.1-beta.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

lru-diskcache

Build Status

A disk cache object that deletes the least-recently-used items. Based on lru-cache.

Usage

var LRU = require("lru-diskcache")

var cache = LRU('./cache', {
    max: 50
});

cache.init()

cache.set("myfile.md", "A string content")
cache.get("file").then(function() { ... }) // Buffer("A string content")

// with a buffer or stream
cache.set("image.png", new Buffer([ ... ]))
cache.set("index.html", request.get("https://www.google.fr"))

cache.reset()    // empty the cache

If you put more stuff in it, then items will fall out.

If you try to put an oversized thing in it, then it'll fall out right away.

API

// Initialize the cache
cache.init()

// Get content as a buffer (return a promise)
cache.get(key)

// Get content as a string
cache.get(key, { encoding: 'utf8' })

// Get content as a stream (return a promise)
cache.getStream(key)

// Check if a key is in the cache, without updating the recent-ness or deleting it for being stale.
cache.has(key)

// Delete a key from the cache
cache.del(key)

// Return total length of objects in cache taking into account
cache.size()

// Manually iterates over the entire cache proactively pruning old entries
cache.prune()

FAQs

Package last updated on 17 Oct 2022

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc