Abstractions and wrappers for datastores.
CoffeeScript JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
src
test
.gitignore
Cakefile
LICENSE.txt
README.md
index.js
package.json

README.md

Stuff

{
  JVR,
  MockKVR
} = require 'datastores'

Abstractions

KV

  • k is an arbitrary Buffer. If you pass a string, it will get UTF-8-encoded.
  • v is an arbitrary Buffer. If you pass a string, it will get UTF-8-encoded.
.set k, v,  (e) ->

.get k,     (e, v) ->p

KVR

KV plus:

.getRange {k__prefix:"foo/", max:50}, (e, items) ->
  for [k, v] in items
    ...

# TODO: implement this:
.getRangeEmitter {...}, (e, itemEmitter) ->
  itemEmitter.on 'item', (k, v) ->
  itemEmitter.on 'end', () ->
  # itemEmitter.pause
  # itemEmitter.resume
  # itemEmitter.destroy

{JV, JVR}

A wrapper around a {KV, KVR} store, keyjson-{en,de}oding the keys.

jv = new JV kv
jv.set [WIKIMEDIA, 'enwiki', articleId, revId], data, (e) ->
jv.getRange k__prefix:[WIKIMEDIA, 'enwiki', articleId], (e, items) ->

SQL

TODO

Engines

MockKVR

  • in-RAM
  • O(total-number-of-items) getRanges so far
kvr = new MockKVR