cachimo ·
Stores key with value in-memory and can be deleted manually or after given timeout.
Installation
npm
npm install cachimo
Yarn
yarn add cachimo
Usage
API
- put
; // Stores element in cache, you can remove it manually whenever you want.// Returns true if element was successfully stored in cache, false if such key already exist.cachimo.put"key", "value";
; // Stores element in cache and it will be deleted after given timeout which returns Promise.cachimo .put"key", "value", 1000 // It will be deleted after 1 sec. and Promise will be resolved or rejected. .then .catch;
; // If you don't want to use Promise you can send callback which will be executed after given timeout.cachimo.put"key", "value", 1000,;
- clear
; // Removes all elements stored in cache and clears all timeouts.// Returns number of how much elements was removed from cache.cachimo.clear;
- get
; // Returns value from cache by given key.cachimo.get"key";
- remove
; // Returns true if element was removed, false otherwise.cachimo.remove"key";
- has
; // Checks if whether an element with given key exists.// Returns true if element exists, false otherwise.cachimo.has"key";
- size
; // Returns the number of elements stored in cache.cachimo.size;
- keys
; // Returns all keys stored in cache.cachimo.keys;
- values
; // Returns all values stored in cache.cachimo.values;
- entries
; // Returns all entries (keys and values) stored in cache.cachimo.entries;
Contributing
Feel free to open issues or PRs!