An open API service indexing awesome lists of open source software.

https://github.com/meckodo/lfu-o1

implement LFU O(1) time
https://github.com/meckodo/lfu-o1

cache cachemanager lfu

Last synced: 7 months ago
JSON representation

implement LFU O(1) time

Awesome Lists containing this project

README

          

# LFU-O1
[![CircleCI](https://img.shields.io/circleci/project/github/MeCKodo/LFU-O1.svg)](https://circleci.com/gh/MeCKodo/wechat-colorpicker) [![npm](https://img.shields.io/npm/dt/lfu-o1.svg)](https://www.npmjs.com/package/lfu-o1) [![npm](https://img.shields.io/npm/v/lfu-o1.svg)](https://www.npmjs.com/package/lfu-o1)
> Implement LFU O(1) time

## Install

> npm install lfu-o1 -S

## How to use

```javascript
const cache = new LFUCache(2);

cache.put(1, 1);
cache.put(2, 2);

cache.get(1); // 1
cache.get(2); // 2
cache.get(2); // 2

cache.put(3, 3); // remove 1

cache.get(1); // -1
cache.get(3); // 3
```