rkv - Ruby Key Value - an adapter on top of various key-value and column stores

Philosophy

The API is a nested (multidimensional) Hash. This allows effective mapping to both column stores and flat KV stores.

For example, if the Cassandra adapter is used, the first dimension is the column family, the second is the row within the CF and the third is the column within the row.

For flat KV stores, a key hierarchy is used for efficient mapping.

Install

Installing the gem:

gem install rkv

Usage

require 'rubygems'
require 'rkv'

store = Rkv.open(:cassandra, { :servers => ['127.0.0.1:9160'], :keyspace => "Blog" })
# store = Rkv.open(:memory, :recurse => {"Users" => "*"})
# store = Rkv.open(:tokyocabinet, :file => "test.tcb", :recurse => {"Users" => "*"})

users = store["Users"]

user = users["5"]
user["name"] = "Dev Random"
user["role"] = "admin"

puts users["3"].inspect

users.batch do
  users[id1]["name"] = "John Doe"
  users[id2]["name"] = "Jane Doe"
end

user_rels = client[:UserRelationships]
user_rels[id1]["posts"][Cassandra::UUID.new] = post_id1

Notes

Keystores have different features. Operations are mapped to the best of the keystore ability, but some operations may be less efficient or impossible in certain keystores.

Documentation

RDoc: rdoc.info/projects/devrandom/rkv

See spec/integration/stores_spec.rb for an example program that runs identically on all stores.

Git:

Supported KV stores

  • Cassandra

  • Memory

  • TokyoCabinet

Planned KV stores

  • Voldemort

  • Redis

  • Keyspace

  • SQL

Roadmap

  • Store support

  • Performance testing

  • Keystore feature support matrix

  • Object mapper?