Gaga, A Git-Backed Key/Value Store

Gaga originated from my winning entry in Codebrawl’s Key/Value Store contest. The challenge was to write the best key/value storage backend you can think of. Since Git is fast, reliable, and a great tool for storing source code, I was really interested in making an easy way to store key/values.

Built with Grit, Gaga supports SET, GET, KEYS, and DELETE operations. And since it’s Git, we can easily enhance it to include other awesome Git features such as branches, diffs, reverting, etc.


@gaga = => '/path/to/repo')

@gaga['lady'] = "gaga"

@gaga['lady'] #=> "gaga"

@gaga.keys  #=> ['lady']

@gaga.delete('lady') #=> 'gaga'

# Remove all items from the store

That works pretty well. Now, we can harness the power of Git and enhance our data store. For example, we can get a history log for a specific key:


# Produces:
 {"message"=>"all clear","committer"=>{"name"=>"Matt Sears", "email"=>""}, "committed_date"=>"2011-09-05..."},
 {"message"=>"set 'lady' ", "committer"=>{"name"=>"Matt Sears", "email"=>""}, "committed_date"=>"2011-09-05..."}
 {"message"=>"delete 'lady' ", "committer"=>{"name"=>"Matt Sears", "email"=>""}, "committed_date"=>"2011-09-05..."}

This is just a start. There’s still a lot things we can add. If you are interested in more detailed information, check out the repo on Github.