0.0.2 • Published 6 years ago

x-lru v0.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

x-lru

Simplified LRU Cache based on Lucky.js

Travis Node Version npm Codecov

Install

$ npm i x-lru --save

API

所有LRU模式的API都是相同的。

1、length: number

获取LRU的长度

2、set(key: string, value: any): void

添加LRU元素,新增的元素会插入到LRU的头部

3、get(key: string): any

获取元素,命中key的元素会移动至LRU的头部

4、peek(): {key: string, value: any}

获取LRU头部元素,但不会删除

Features

  • LRU-1
  • LRU-2
  • MultiQueue
  • TwoQueues

Example

'use strict';

const {LRU} = require('x-lru');
const lru = new LRU({maxSize: 100});


lru.set('one', 1);
console.log(lru.length); // 1

Author

Lucky.js © Ricky 泽阳, Released under the MIT License.

0.0.2

6 years ago

0.0.1

6 years ago