Socket
Socket
Sign inDemoInstall

@swarmy/lru-cache

Package Overview
Dependencies
0
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @swarmy/lru-cache

LRU cache with event registry to handle cache changes


Version published
Weekly downloads
5
decreased by-28.57%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

lru-cache

A Javascript LRU-cache for node and/or browser, featuring:

  • LRU cache logic
  • Singleton caches per value type
  • Event registry for cache change events

Installation

npm install --save @swarmy/lru-cache

Basic Usage

Caching

import {getCache} from "@swarmy/lru-cache";
// If you use in nodejs and prefer the old-fashioned way:
// var getCache = require("@swarmy/lru-cache").getCache;

...
const userCache = getCache("User");
userCache.set(user.id, user);
...
let user = userCache.get(userId);
if (!user) {
    await fetchUser(userId);
}
  • For the same value type (here "User"), getCache will always return the same cache instance.
  • For detailed description of all cache methods, have a look at
    • Detailed Usage
    • JSDoc

Cache Events

WIP

Quality

Develop

git clone https://github.com/gneu77/lru-cache.git
cd lru-cache
npm install
// no you can do:
npm run build
npm run test
npm run generate-doc

Detailed Usage

Caching

WIP

Cache Events

WIP

Keywords

FAQs

Last updated on 01 Dec 2018

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