casket.js
v0.1.3
Published
a lightweight key-value store written in js
Downloads
11
Readme
casket.js
a lightweight key-value store for browser
installation
using yarn
yarn add casket.js
using npm
npm i casket.js
usage
const casket = new Casket();
// with no expires
casket.set('k', 'v');
casket.set('k2', 'v2');
// expires in 10 seconds
casket.exp(10);
// same as
casket.set('k', 'v', 10);
// no expires
casket.exp(0);
// get key
casket.get('k'); // result: v
// you can also get multi-key object or array like blow
casket.get({ foo: 'k', bar: 'k2' }); // result: { foo: 'v', bar: 'v2' }
casket.get('k', 'k2'); // result: ['v', 'v2']
// delete a key
casket.del('k');
// delete multiple keys
casket.del('k', 'k1');
// get casket size
casket.size();
// get all keys
casket.keys();
// truncate casket
casket.empty();
// create a casket with scope name
new Casket(); // default: 0
new Casket(1);
new Casket(2);
new Casket('other casket');