All Projects → gruns → Immortaldb

gruns / Immortaldb

Licence: mit
🔩 A relentless key-value store for the browser.

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
shell
77523 projects

Projects that are alternatives of or similar to Immortaldb

Gokv
Simple key-value store abstraction and implementations for Go (Redis, Consul, etcd, bbolt, BadgerDB, LevelDB, Memcached, DynamoDB, S3, PostgreSQL, MongoDB, CockroachDB and many more)
Stars: ✭ 314 (-89.4%)
Mutual labels:  database, key-value, key-value-store, library
persistence
💾 Persistence provides a pretty easy API to handle Storage's implementations.
Stars: ✭ 18 (-99.39%)
Mutual labels:  storage, localstorage, indexeddb, sessionstorage
stoor
Storage wrapper with support for namespacing, timeouts and multi get/set and remove.
Stars: ✭ 26 (-99.12%)
Mutual labels:  storage, localstorage, sessionstorage
Unqlite
An Embedded NoSQL, Transactional Database Engine
Stars: ✭ 1,583 (-46.56%)
Mutual labels:  database, storage, key-value
vue-web-storage
Vue.js plugin for local storage and session storage (1.8 kb min+gz) 💾
Stars: ✭ 85 (-97.13%)
Mutual labels:  storage, localstorage, sessionstorage
client-persist
Offline storage for your web client. Supports IndexedDB, WebSQL, localStorage and sessionStorage with an easy to crawl with API.
Stars: ✭ 14 (-99.53%)
Mutual labels:  localstorage, indexeddb, sessionstorage
Pufferdb
🐡 An Android & JVM key-value storage powered by Protobuf and Coroutines
Stars: ✭ 91 (-96.93%)
Mutual labels:  database, storage, key-value-store
Olric
Distributed cache and in-memory key/value data store. It can be used both as an embedded Go library and as a language-independent service.
Stars: ✭ 2,067 (-30.22%)
Mutual labels:  database, key-value, key-value-store
Keyvast
KeyVast - A key value store
Stars: ✭ 33 (-98.89%)
Mutual labels:  database, key-value, key-value-store
Cubdb
Elixir embedded key/value database
Stars: ✭ 235 (-92.07%)
Mutual labels:  database, key-value, key-value-store
Filebase
A Simple but Powerful Flat File Database Storage.
Stars: ✭ 235 (-92.07%)
Mutual labels:  database, storage, key-value
svelte-persistent-store
A Svelte store that keep its value through pages and reloads
Stars: ✭ 111 (-96.25%)
Mutual labels:  localstorage, indexeddb, sessionstorage
Cog
A Persistent Embedded Graph Database for Python
Stars: ✭ 90 (-96.96%)
Mutual labels:  database, key-value, library
Pumpkindb
Immutable Ordered Key-Value Database Engine
Stars: ✭ 1,219 (-58.85%)
Mutual labels:  database, storage, key-value
Badger
Fast key-value DB in Go.
Stars: ✭ 10,127 (+241.9%)
Mutual labels:  database, key-value, library
Cutedb
A slick BTree on disk based key value store implemented in pure Go
Stars: ✭ 67 (-97.74%)
Mutual labels:  database, key-value, key-value-store
ng2-storage
A local and session storage wrapper for angular 2.
Stars: ✭ 14 (-99.53%)
Mutual labels:  storage, localstorage, sessionstorage
Nano Sql
Universal database layer for the client, server & mobile devices. It's like Lego for databases.
Stars: ✭ 717 (-75.79%)
Mutual labels:  database, indexeddb, localstorage
Dexie.js
A Minimalistic Wrapper for IndexedDB
Stars: ✭ 7,337 (+147.7%)
Mutual labels:  database, storage, indexeddb
Iowow
The skiplist based persistent key/value storage engine
Stars: ✭ 206 (-93.05%)
Mutual labels:  database, key-value, key-value-store

ImmortalDB

ImmortalDB

ImmortalDB is a resilient key-value store for the browser.

ImmortalDB is the best way to store persistent key-value data in the browser. Data saved to ImmortalDB is redundantly stored in Cookies, IndexedDB, and LocalStorage, and relentlessly self heals if any data therein is deleted or corrupted.

For example, clearing cookies is a common user action, even for non-technical users. And browsers unceremoniously delete IndexedDB, LocalStorage, and/or SessionStorage without warning under storage pressure.

ImmortalDB is resilient in the face of such events.

In this way, ImmortalDB is like Evercookie, but

  1. Is actively maintained and well documented.

  2. Provides a simple, modern, Promise-based API.

  3. Strikes an equitable balance between reliability and respect for the user. Data is stored reliably but can also be voluntarily purged if the user designedly clears cookies and application storage.

  4. Doesn't use nefarious exploits nor deprecated third party plugins like Flash, Silverlight, or Java. Only standard, ratified HTML5 APIs are used.

  5. Doesn't vandalize performance or the user experience. For example, Evercookie's CSS History Knocking can beget a deluge of background HTTP requests, and loading Silverlight or Flash can raise unsought permission modals or thrash the user's disk.

How ImmortalDB works.

When you store a key-value pair in ImmortalDB, that key and value are saved redundantly in the browser's cookies, IndexedDB, and LocalStorage data stores.

When a value is retrieved via its key, ImmortalDB

  1. Looks up that key in every data store.
  2. Counts each unique returned value.
  3. Determines the most commonly returned unique value as the 'correct' value.
  4. Returns this correct value.

Then ImmortalDB self-heals: if any data store(s) returned a value different than the determined correct value, or no value at all, the correct value is rewritten to that store. In this way, consensus, reliability, and redundancy is maintained.

API

Set

ImmortalDB's API is simple. To store a value, use set(key, value):

import { ImmortalDB } from 'immortal-db'

await ImmortalDB.set('key', 'value')

key and value must be DOMStrings. ImmortalDB.set(key, value) also always returns value, so it can be chained or embedded, like

const countPlusOne = (await ImmortalDB.set('count', numberOfClowns)) + 1

Get

To retrieve a value, use get(key, default=null):

const value = await ImmortalDB.get('key', default=null)

get() returns the value associated with key, if key exists. If key doesn't exist, default is returned. key must be a DOMString.

Remove

Finally, to remove a key, use remove(key):

ImmortalDB.set('hi', 'bonjour')
console.log(await ImmortalDB.get('hi'))  // Prints 'bonjour'.

await ImmortalDB.remove('hi')

console.log(await ImmortalDB.get('hi'))  // Prints 'null'.

key must be a DOMString.

Data Stores

The data stores that ImmortalDB stores data in can also be configured. For example, this is how to store data reliably in cookies and LocalStorage only:

import { ImmortalStorage, CookieStore, LocalStorageStore } from 'immortal-db'

const stores = [await CookieStore(), await LocalStorageStore()]
const db = new ImmortalStorage(stores)

await db.set(key, JSON.stringify({1:1}))

By default, stores used by ImmortalDB are:

  • CookieStore -> Keys and values are stored in document.cookie.
  • IndexedDbStore -> Keys and values are stored in window.indexedDB.
  • LocalStorageStore -> Keys and values are stored in window.localStorage.

Other, optional stores are:

  • SessionStorageStore -> Keys and values are stored in window.sessionStorage.

New storage implementations can easily be added, too; they need only implement the async methods get(key, default), set(key, value), and remove(key).

Installation

Installing ImmortalDB with npm is easy.

$ npm install immortal-db

Or include dist/immortal-db[.min].js and use window.ImmortalDB directly.

<html>
  <head>
    <script src="immortal-db.min.js"></script>
    <script>
      ;(async () => {
        const db = ImmortalDB.ImmortalDB
        await db.set('hi', 'lolsup')
      })()
    </script>
  </head>

  ...
</html>

Development

To test ImmortalDB, run

npm run start

This starts a webpack dev server and opens ImmortalDB's testing website, http://localhost:9234/.

Once tested, to produce new production-ready files immortal-db.js and immortal-db.min.js in dist/, run

npm run build
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].