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

@alloc/quick-lru

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

@alloc/quick-lru

Simple “Least Recently Used” (LRU) cache

  • 5.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.2M
increased by0.15%
Maintainers
1
Weekly downloads
 
Created

What is @alloc/quick-lru?

The @alloc/quick-lru package is a fast, lightweight least recently used (LRU) cache implementation. It is designed to efficiently store and retrieve items based on their usage, ensuring that the most recently accessed items are kept in memory while older items are discarded when the cache reaches its capacity. This package is useful for optimizing performance in applications where accessing data from memory is preferable to repeatedly fetching it from slower sources like databases or file systems.

What are @alloc/quick-lru's main functionalities?

Creating and using an LRU cache

This feature demonstrates how to create an LRU cache with a maximum size, add an item to the cache, retrieve an item, check if an item exists in the cache, and delete an item from the cache.

{"const QuickLRU = require('@alloc/quick-lru');\nconst lru = new QuickLRU({ maxSize: 100 });\nlru.set('key', 'value');\nconsole.log(lru.get('key')); // 'value'\nconsole.log(lru.has('key')); // true\nlru.delete('key');\nconsole.log(lru.has('key')); // false"}

Iterating over cache items

This feature shows how to iterate over the items in the cache. It's useful for scenarios where you need to perform operations on all items stored in the cache.

{"const QuickLRU = require('@alloc/quick-lru');\nconst lru = new QuickLRU({ maxSize: 2 });\nlru.set('a', 1);\nlru.set('b', 2);\nfor (const [key, value] of lru) {\n  console.log(key, value);\n}"}

Other packages similar to @alloc/quick-lru

Keywords

FAQs

Package last updated on 06 Apr 2021

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