University project, integrates use of Tokyo Cabinet / Tyrant in a Ruby on Rails web application for posting and viewing events and locations. Includes TokyoRecord, a tiny wrapper around rufus-tokyo for accessing Tokyo Tyrant tables. Tyrant instances are managed with tyrantmanager.
The basic idea is to store some data which is written frequently in Tokyo Cabinet tables, as benchmarks show that it is much faster than ActiveRecord and MySQL. So there are three such tables: for storing page views, event presences and event highlights.
Install Tokyo Cabinet and Tokyo Tyrant. On Ubuntu, you usually need to install this library before that:
apt-get install libbz2-dev
Get the latest sources from the Tokyo website, unpack and do the ./configure && make && sudo make install
thing.
Install all required gems:
sudo rake gems:install
Copy database.yml and adjust it to your MySQL setup:
cp config/database.yml.example config/database.yml
You may wish to generate some fake data:
rake db:bootstrap
There’s a script which will tell tyrantmanager to run all the Tyrant instances and boot Mongrel:
./script/launch
One of the Tyrant tables is called Highlights, for simulating the case of serving variable data on a homepage that gets a lot of views. You can populate it with random events with the following rake task:
rake events:highlight
Eventually you’ll see something like
To run the test suite, you need to manually run two Tyrant instances on expected ports:
ttserver -port 19851 page_views.tct
ttserver -port 19861 presences.tct
Copyright © 2009 Marko Anastasov
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.