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).
Let's trust the filesystem.
There is no dump.
The indexes are in the document id.
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.
The tests for glaive are written in Ruby, they fork a glaive server manipulate it.
glaive $ rake test
or
glaive $ ruby test/test.rb
MIT