Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

a key-document store (JSON docs), a golang experiment

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 src
Octocat-spinner-32 test
Octocat-spinner-32 CHANGELOG.txt
Octocat-spinner-32 LICENSE.txt
Octocat-spinner-32 Makefile
Octocat-spinner-32 README.mdown
Octocat-spinner-32 Rakefile
Octocat-spinner-32 TODO.txt
README.mdown

glaive

A 'golang' experiment.

It's a naive key-value store, where values are JSON documents. Those documents are expected to have a type, an _id and glaive adds an integer _rev (revision) to them (yes, this is CouchDB-inspired).

Documents are stored on disk, in a hierarchy {type}/{subdir}/{id}.json where subdir is the last two chars of the id.

A client when putting or deleting a document is expected to provide the current _rev, else the operation (put or delete) fails and the current version of the document is returned.

Glaive is derived from work on "rufus-cloche":http://github.com/jmettraux/rufus-cloche (ruby) and "cloche":http://github.com/jmettraux/cloche (erlang).

philosophy (or lack of)

Let's trust the filesystem.

There is no dump.

The indexes are in the document id.

API

All replies are encoded in JSON. Returns a string in case of error.

  • put {type}\r\n {json_doc}\r\n

Stores a document. Expects the document to have a "type" and an "_id" attribute.

  • get {type} {id}\r\n

Given a type and an id, returns the corresponding document or null if none.

  • delete {type} {id} {rev}\r\n

Given a type, an id and a rev, deletes the corresponding document. Will return -1 if the document is already gone (or didn't previously exist). Will return the current doc if the rev given is wrong. In case of success returns the given rev.

  • get_many {type} [regex]\r\n

  • ids {type}

Returns a list of all the ids stored for the given type.

  • purge\r\n

Removes all the documents in glaive. Dangerous.

running tests

The tests for glaive are written in Ruby, they fork a glaive server manipulate it.

glaive $ rake test

or

glaive $ ruby test/test.rb

license

MIT

Something went wrong with that request. Please try again.