0.0.7 • Published 12 months ago

lru-cache-lite v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

lru-cache-lite

迷你型 LRU 实现库。如果你有轻量的 LRU 需求,那么推荐你试试。

NPM

English | 简体中文

功能

  1. 支持设置缓存内容数量
  2. 支持设置每一条缓存过期时间

使用

step1: 引入文件,并初始化

import LRUCacheLite from  "lru-cache-lite"

const cacheIns = new LRUCacheLite(10); // 指定缓存数量为10

step2: 设置缓存或读取缓存

// 设置缓存 set(key, value, expireTime(秒) ), 
cacheIns.set('demo', 'demo-value', 10)

// 读取缓存
cacheIns.get('demo') // 'demo-value'

const objKey = {};

const objValue = {};

cacheIns.set(objKey, objValue)

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

建议使用场景

  1. 前端做接口缓存
  2. 前端业务内容的缓存处理

:copyright: License

MIT

0.0.7

12 months ago

0.0.6

12 months ago

0.0.5

12 months ago

0.0.4

12 months ago

0.0.3

12 months ago

0.0.1

12 months ago

0.0.0

12 months ago