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

@skylab/lru

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@skylab/lru

Basic LRU cache library.

  • 1.0.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

node-lru

A simple LRU (Least Recently Used) cache implementation.

What it does?

It takes a getter function as first argument and the size of cache (max key value pairs) as the second argument. The function is called when there is a cache miss.

Installation

foo@bar:src$ npm install @skylab/node-lru

Usage

function getValue(key){
  //calculate or get value remotely query/db/ajax etc.
  return value;
}

let LRU = require('@skylab/node-lru')
let cache = new LRU(getValue, 50);

const key = 10;
console.log(cache.get(10)); // getValue function is called to get value and stored in cache , if the cache is full the oldest accessed value is purged

console.log(cache.get(10)); // the value is retrieved from cache.

Alternatives

Todo

  • Documentation
  • Add Test

Keywords

FAQs

Package last updated on 14 Jun 2019

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