ImmutableDB is an interface for content-addressed storage systems as databases.
ImmutableDB is specified as:
- same data always returns the same key (write)
- same key always returns the same data (read)
The difference to traditional relational databases, document databases or key-value stores is that the key doesn't get specified explicitly by the user. Instead, the key gets calculated based on the data using a hashing function. This is also called content-addressed storage.
In practice this means that saving hello world
to an ImmutableDB will always return key abc
regardless of which instance or location the data is saved at and saving hello world!
will return cba
. In turn, querying the value of key abc
will always return hello world
, regardless of instance and location.
Save value
to database and return a key
.
Example:
var key = put("hello world")
console.log(key)
// "abc"
Retrieve the value of key
from the database.
Example:
var data = get("abc")
console.log(data)
// "hello world"
ImmutableDB can be used via the following implementations:
- immutabledb-fs - Uses local file system as the storage backend
- immutabledb-ipfs - Uses IPFS as the storage backend
- immutabledb-ipld - In-memory storage that uses IPLD data structures
- immutabledb-leveldb - Uses LevelDB as the storage backend
- immutabledb-mongodb - Uses MongoDB as the storage backend
- immutabledb-redis - Uses Redis as the storage backend
- immutabledb-tendermint - Uses Tendermint as the storage backend
- immutabledb-mem - In-memory storage (useful eg. for testing)
New backend implementations, PRs and discussion are gladly accepted!