/
README.txt
106 lines (51 loc) · 2.39 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
= Rufus::Edo
wrapping Hirabayashi-san's 'native' ruby bindings into a rubiyst-friendly set of Ruby classes.
In order to use Rufus::Edo, you have to have the libtokyocabinet dynamic library installed on your system :
http://openwferu.rubyforge.org/tokyo.html
Then you can install the 'native' C bindings.
NOTE : I have only tested those native bindings with Ruby 1.8.6. To run them with JRuby, the best option is Rufus::Tokyo and its FFI bindings.
NOTE : the Ruby tyrant library provided by Hirabayashi-san is not a C binding, it's a pure Ruby connector. It is slower than Rufus::Tokyo::Tyrant and Rufus::Tokyo::TyrantTable, but the advantage is that there is no need to install cabinet and tyrant C libraries to connect your Ruby code to your Tokyo Tyrant.
== installation of the 'native' C bindings
=== Careo's mirror gem
sudo gem install careo-tokyocabinet --source http://gems.github.com
=== directly from http://sf.net/tokyocabinet
Get the tokyocabinet-ruby package at :
http://sourceforge.net/project/showfiles.php?group_id=200242
unpack it :
tar xzvf tokyocabinet-ruby-1.20.tar.gz
cd tokyocabinet-ruby-1.20
and then, as described at : http://tokyocabinet.sourceforge.net/rubydoc/
ruby extconf.rb
make
sudo make install
== Rufus::Edo::Cabinet
require 'rufus/edo' # sudo gem install rufus-tokyo
db = Rufus::Edo::Cabinet.new('data.tch')
db['a'] = 'alpha'
# ...
db.close
== Rufus::Edo::Table
require 'rufus/edo'
db = Rufus::Edo::Table.new('data.tct')
db['customer1'] = { 'name' => 'Taira no Kyomori', 'age' => '55' }
# ...
db.close
== tyrant
Hirabayashi-san's pure Ruby gem for accessing Tokyo Tyrant can be installed with :
sudo gem install careo-tokyotyrant --source http://gems.github.com
It's also available at :
http://sourceforge.net/project/showfiles.php?group_id=200242
http://github.com/careo/tokyotyrant-ruby
== Rufus::Edo::NetTyrant
Note : 'NetTyrant' instead of 'Tyrant' to clearly show that this class isn't a C binding but a simple [pure Ruby] network implementation of a connection to a Tyrant.
require 'rufus/edo/ntyrant'
db = Rufus::Edo::NetTyrant.new('127.0.0.1', 45000)
db['a'] = 'alpha'
puts db['a]
# => 'alpha'
db.close
== Rufus::Edo::NetTyrantTable
require 'rufus/edo/ntyrant'
t = Rufus::Edo::NetTyrantTable.new('127.0.0.1', 44502)
t['client0'] = { 'name' => 'Heike no Kyomori', 'country' => 'jp' }
t.close