1.0.0 • Published 2 years ago
supercache.js v1.0.0
Install
yarn add supercache.js
npm i supercache.js
...
Methods
get
// Get the value of a key by its key.
Cache.put("foo", "bar");
Cache.get("foo"); // -> 'bar'
Cache.get("foo_"); // -> 'undefined'
exist
// Checks if an element exists using its key.
Cache.put("foo", "bar");
Cache.exist("foo"); // -> true
Cache.exist("foo_"); // -> false
del
// Delete element by key.
Cache.put("foo", "bar");
Cache.del("foo"); // -> true
Cache.del("foo_"); // -> undefined
put
// Enter a new item.
Cache.put("foo", "bar", 1, 4, true);
deleteByKeyInTime
//Delete an element by its key in a given time.
Cache.put("foo", "bar");
Cache.deleteByKeyInTime("foo", 10000);
show
// Show cache
Cache.show();
putInTime
// Enter an element in a certain time.
Cache.putInTime("foo", 10000, 1, 2, 3, true);
resetInTime
// 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);
same
// 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
// Set a value of an element already entered previously.
Cache.put("foo", "bar");
Cache.set("foo", "bar1");
Cache.set("foo1", "bar"); // -> false
size
// Return size of cache.
Cache.put("foo0", "bar");
Cache.put("foo1", "bar");
Cache.put("foo2", "bar");
Cache.size; // -> 3
Extends
Since "Cache" is a class, it can be extended.
const { Cache } = require("supercache.js");
class extendCache extends Cache {
static void__ = "foo";
}
extendCache.void__; // -> 'foo'
1.0.0
2 years ago