Code Monkey home page Code Monkey logo

ururu's Introduction

ururu

Maintenance GitHub repo size Static Badge PRs Welcome


Table of Contents

๐Ÿข First-In-First-Out (FIFO) Cache

๐Ÿ Random Replacement (RR) Cache

Tip

Code is ready for copy-paste. Use plain TS files or JS + type annotations, whatever you need.

Motivation

Yet another cache implementations. But why? Yeah, there are a few reasons for that.

Major reasons:

  1. Research.
  2. Education.
  3. Fun.

Minor reasons:

  1. To produce ready-to-use library well enough to just copy-paste into real project.

There are also several let's say acceptance criteria and non-functional requirements which I follow here:

  1. Simplicity in implementation means better maintainability.

If in general it's usually true, this is very subjective if applied to implementations in this repository. Despite the fact that I try to maintain the lowest complexity level as it's possible and reasonable (without damage to performance in the first place), some specific decisions could probably be simplified.

  1. Simplicity in interface means better learnability (see "ISO/IEC 9126 Software engineering โ€” Product quality").

  2. Zero dependencies to achieve better predictability, safety, reduces overall application size and CI/CD duration.

General Theory

When the cache becomes full, a cache block or record/entry must be evicted to make room for a new block. The replacement policy determines which block to evict.

Various cache implementations can have slightly different public APIs, however most of them are very consistent in their core capabilities. In the list below there are typical extra features which can be found in known cache realisations (as part of their public API):

Member Type Description
size property Number of entries/items/records actually stored in cache ($size <= capacity$).
from static Instantiate cache with data (usually key-value structure).
setpop method Sets a value for the given key, but besides that returns evicted object or old value.
peek method Retrieves the value associated with the given key, doesn't update access information.
forEach method Convenient helper methods implementing the ability to iterate on cache data.
keys method
values method
entries method

ururu's People

Contributors

zhibirc 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.