GithubHelp home page GithubHelp logo

tml / arc-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alexandergugel/arc-js

0.0 3.0 0.0 60 KB

:hear_no_evil: An Adaptive Replacement Cache (ARC) written in JavaScript.

License: ISC License

JavaScript 100.00%

arc-js's Introduction

Build Status js-standard-style

arc-js

An Adaptive Replacement Cache (ARC) written in JavaScript.

Looking for the Go version? alexanderGugel/arc

Overview

This project implements "ARC", a self-tuning, low overhead replacement cache. The goal of this project is to follow the algorithm outlined in the linked research paper as closely as possible. ARC uses a learning rule to adaptively and continually revise its assumptions about the workload in order to adjust the internal LRU and LFU cache sizes.

This implementation is based on Nimrod Megiddo and Dharmendra S. Modha's "ARC: A SELF-TUNING, LOW OVERHEAD REPLACEMENT CACHE", while definitely useable, this is still an experiment and shouldn't be considered production-ready.

<------- cache size c ------>
+-----------------+----------
| LFU             | LRU     |
+-----------------+----------
                  ^
                  |
                  p (dynamically adjusted by learning rule)

B1 [...]
B2 [...]

The cache is implemented using two internal caching systems L1 and L2. The cache size c defines the maximum number of entries stored (excluding ghost entries). Ghost entries are being stored in two "ghost registries" B1 and B1. Ghost entries no longer have a value associated with them.

Ghost entries are being used in order to keep track of expelled pages. They no longer have a value associated with them, but can be promoted into the internal LRU cache.

Frequently requested pages are being promoted into the LFU.

Install

With npm do:

npm i arc-js

Usage

var mainStorage = {
  get: function (key) {
    // User specific logic (FS/ DB interaction)
    return value
  }
}

// c = 10: Cache size
// mainStorage = slow storage medium
var arc = new ARC(10, mainStorage)

// Retrieves my_key from cache (uses the mainStorage if item is not cached)
var value = arc.request('my_key')

TODO

  • More tests (remove randomized tests)
  • Careful code review
  • Review API

License

See LICENSE file.

arc-js's People

Contributors

alexandergugel avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.