cache-result: For Caching Nested Results
source link: https://github.com/jalal246/cache-result
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
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 key: string
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
-
builderz - Zero Configuration JS bundler.
-
packageSorter - Sorting packages for monorepos production.
-
corename - Extracts package name.
-
move-position - Moves element index in an array.
-
get-info - Utility functions for projects production.
-
textics & textics-stream - Counts lines, words, chars and spaces for a given string.
-
folo - Form & Layout Components Built with React.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK