1.0.4 • Published 1 year ago

blaze-cache v1.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

BLAZE-CACHE

This package provides a simple utility for caching the results of functions based on their input arguments. By caching previously computed results. The caching mechanism uses LRU(Least recently Used) cache method to store results.

How to use it

const {cache} = require('blaze-cache');
// or
import {cache} from "blaze-cache"

// program to display fibonacci sequence using recursion

function fibonacci(num) {
    if(num < 2) {
        return num;
    }
    else {
        return fibonacci(num-1) + fibonacci(num - 2);
    }
}

const result=cache(fibonacci)(40) // it will memoize the fibonacci function and return cached value

// PS: cache(somefunc,capacity) capacity argument will define the capacity of LRU cache
1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago