lru-cache-lite

0.0.7 • Public • Published

lru-cache-lite

A mini LRU implementation library. If you have lightweight LRU needs, we recommend you give it a try.

NPM

English | 简体中文

Features

  1. Supports setting the number of cache entries
  2. Supports setting the expiration time for each cache entry

Usage

step1: import the file and initialize

import LRUCacheLite from  "lru-cache-lite"

const cacheIns = new LRUCacheLite(10); // Specify the cache size as 10

step2: Set or read the cache

// Set cache with set(key, value, expireTime(seconds)) 
cacheIns.set('demo', 'demo-value', 10)

// Read cache
cacheIns.get('demo') // 'demo-value'

const objKey = {};

const objValue = {};

cacheIns.set(objKey, objValue)

console.log(objValue === cacheIns.get(objKey)) // true

Recommended Use Cases

  1. Front-end API interface caching
  2. Front-end business content caching

©️ License

MIT

Readme

Keywords

Package Sidebar

Install

npm i lru-cache-lite

Weekly Downloads

0

Version

0.0.7

License

MIT

Unpacked Size

5.28 kB

Total Files

5

Last publish

Collaborators

  • harrypoint