yarn add supercache.js
npm i supercache.js
...
// Get the value of a key by its key.
Cache.put("foo", "bar");
Cache.get("foo"); // -> 'bar'
Cache.get("foo_"); // -> 'undefined'
// Checks if an element exists using its key.
Cache.put("foo", "bar");
Cache.exist("foo"); // -> true
Cache.exist("foo_"); // -> false
// Delete element by key.
Cache.put("foo", "bar");
Cache.del("foo"); // -> true
Cache.del("foo_"); // -> undefined
// Enter a new item.
Cache.put("foo", "bar", 1, 4, true);
//Delete an element by its key in a given time.
Cache.put("foo", "bar");
Cache.deleteByKeyInTime("foo", 10000);
// Show cache
Cache.show();
// Enter an element in a certain time.
Cache.putInTime("foo", 10000, 1, 2, 3, true);
// Reset the cache in a certain time. **If the parameter is of type string and says "null" the cache will be reset instantly.**
Cache.resetInTime(10000);
// Returns all keys with the same value.
Cache.put("foo0", "bar");
Cache.put("foo1", "bar");
Cache.put("foo2", "bar");
Cache.same("bar"); // -> ["foo0", "foo1", "foo2"]
// Set a value of an element already entered previously.
Cache.put("foo", "bar");
Cache.set("foo", "bar1");
Cache.set("foo1", "bar"); // -> false
// Return size of cache.
Cache.put("foo0", "bar");
Cache.put("foo1", "bar");
Cache.put("foo2", "bar");
Cache.size; // -> 3
Since "Cache" is a class, it can be extended.
const { Cache } = require("supercache.js");
class extendCache extends Cache {
static void__ = "foo";
}
extendCache.void__; // -> 'foo'