Skip to content

shanna/dm-tokyo-adapter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DataMapper Tokyo Cabinet/Tyrant Table Store Adapter

Description

A DataMapper Tokyo Cabinet/Tyrant table store adapter.

Table Store

tokyocabinet.sourceforge.net/spex-en.html#features_tctdb

The Tokyo Cabinet table storage engine doesn’t require a predefined schema and as such properties in your resource are only used for by the adapter for typecasting. There is no need to migrate your resource when you create, update or delete properties.

Dependencies

Ruby
  • dm-core ~> 0.10.0

  • rufus-tokyo ~> 0.1.12

Install

  • Via gem:

    gem install shanna-dm-tokyo-adapter -s http://gems.github.com
  • Via git:

    git clone git://github.com/shanna/dm-tokyo-adapter.git
    rake install

Synopsis

# Tokyo Cabinet DB files will be located in #{path}/#{database}/#{resource}.tdb
DataMapper.setup(:default,
  :adapter  => 'tokyo_cabinet',
  :database => 'tc',
  :path     => File.dirname(__FILE__)
)

# Tokyo Tyrant connection.
DataMapper.setup(:default,
  :adapter  => 'tokyo_tyrant',
  :host     => 'localhost',
  :port     => '1978'
)

# Define your DataMapper resource and start saving:
class User
  include DataMapper::Resource
  property :id, Serial
  property :name, String
  property :age, Integer
end

# No need to (auto_)migrate!
User.create(:name => 'Fred', :age => '25')

# Conditions:
users = User.all(:age.gte => 10, :limit => 20, :order => [:age.asc])

TODO

  • Documentation. It’s undocumented at the moment.

  • Give access to the Rufus::Tokyo::Table object through the adapter. Handy if you want to add indexes and other things that can’t be done through the DataMapper API.

  • Better tests. I haven’t really tested all the DM primitives and query operators yet.

  • Better typecasting. DataTime and Time should typecast to Integer so that they can be searched using the numeric operators.

Ideally in the future I’d like to contribute to these broader goals:

  • All the TokyoCabinet stores equally supported in DM.

  • DataMapper define a public/semipublic API for key => value and search stores through Moneta (memcachedb, memcacheq, couchdb, mtokyo cabinet bdb, etc.)

  • DataMapper per adapter query operators. You can’t always shoehorn everything into an SQL mindset.

Contributing

Go nuts. Just send me a pull request (github or otherwise) when you are happy with your code.

Copyright © 2009 “Shane Hanna”. See LICENSE for details.

About

Tokyo Cabinet/Tyrant Table Store DataMapper Adapters

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages