Jabberwocky

snicker-snack!

Tokyo Cabinet Plugin for Rails

| Comments

I made a Rails plugin as a kind of adapter for Tokyo Cabinet. Tokyo Cabinet, apart from having a funny name, is a database engine from (duh) Japan, allowing a few different data storage paradigms.

I got to know it through this post of Ilya Grigorik where he basically says it’s blazingly fast. And when he says it’s fast, I tend to believe him.

So what did I use it for ? I needed to do a multiple shortest path calculation, using the Floyd-Warshall algorithm. I figured storing intermediate results in a Tokyo B+Tree, and table database (for random-length paths) is certainly faster than storing it in your garden variety relational database. It’s definitely slower than doing results in memory … until it isn’t. Storing everything in memory is not a good idea if you want your calculation to be scalable to any size of graph.

I wrote this small plugin tokyo_cabinet4r, which has no greater ambition than to make the use of Tokyo Cabinet in Rails easier, and to a certain extent similar to the use of ActiveRecord (using the Ruby API). If you have any suggestion at all, or you want to use it and a feature’s lacking, let me know. I’ll probably fine-tune and fiddle with it in the next few days, amongst other things.

Comments