Git Product home page Git Product logo

cache-result's Introduction

cache-result

You cache the results you know when to flush'em

npm install cache-result

It deals with nested cache without taking size into consideration. Instead, you decided what part of caching is not related anymore and what part should be preserved.

Usage

const cache = require("cache-result");

const { set, get, clear } = cache();

Each function take object input:

  • branch: string - To set working branch for cache
  • key: string - key to value in cache

set({ branch, key }, result)

get({ branch, key })

clear({ branch, key })

To delete the whole branch pass clear({ branch }) without key

const cache = require("../src");

const { set, get, clear } = cache();

set({ branch: "foo", key: "hello" }, "sunshine");
set({ branch: "bar", key: "by" }, "sunset");

get({ branch: "foo", key: "hello" }); // sunshine
get({ branch: "bar", key: "by" }); // sunset

clear({ branch, "foo" });
get({ branch: "foo", key: "hello" }); // null
get({ branch: "bar", key: "by" }); // sunset

Test

npm test

License

This project is licensed under the GPL-3.0 License

Related projects

cache-result's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar jalal246 avatar renovate-bot avatar

Stargazers

 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.