Storage.js - localStorage on steroids
Storage.js is the result of the pain using the default localStorage and sessionStorage api interface and possibilities.
Inspired by Redis, I created a wrapper with the same api methods but localStorage as the storage container.
Usage
var db = Storage.select("mydb");
db.set("mykey", 1);
db.incr("mykey");
db.get("mykey"); // 2
// Lists
db.rpush("mylist", "item1");
db.rpush("mylist", "item2");
db.lpush("mylist", "item3");
db.get("mylist"); // ["item3", "item1", "item2"]
// hashes
db.hset("myhash", "myfield", 1);
db.hmset("myhash", "myfield-1", "value-1", "myfield-2", "value-2");
db.hkeys("myhash"); // ["myfield", "myfield-1", "myfield-2"]
db.hvals("myhash"); // [1, "value-1", "value-2"]
db.hget("myhash", "myfield"); // 1
db.get("myhash"); // {"myfield":1, "myfield-1":"value-1", "myfield-2":"value-2"}
** implemented methods**
set, get, exists, del, type, append, incr, decr,
llen, lpush, rpush, lset, lindex,
hset, hget, hgetall, hexists, hkeys, hvals, hlen, hincrby, hmset, hmget
Written by Artur
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Js
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#