Skip to content
Newer
Older
100644 333 lines (194 sloc) 7.54 KB
2a5b11b @jmettraux initial commit
authored
1
2 = rufus-tokyo
3
5fd2ac1 @jmettraux more doc and a stop spec ttservers
authored
4 ruby-ffi based interface to Tokyo Cabinet and Tokyo Tyrant.
521d51e @jmettraux more doc
authored
5
910413a @jmettraux maintenance mode
authored
6 NOTE : this library is in "maintenance mode", see
7
8 http://jmettraux.wordpress.com/2010/02/26/retiring-rufus-tokyo/
9
10 for the explanation
2a5b11b @jmettraux initial commit
authored
11
6e5c50f @jmettraux extended README + rufus-tokyo.rb
authored
12
13 == installation
14
98fe6e6 @jmettraux updated links (and --source http://gemcutter.org)
authored
15 sudo gem install rufus-tokyo --source http://gemcutter.org
6e5c50f @jmettraux extended README + rufus-tokyo.rb
authored
16
5fd2ac1 @jmettraux more doc and a stop spec ttservers
authored
17 (see after 'usage' for how to install Tokyo Cabinet (and Tyrant) if required)
6e5c50f @jmettraux extended README + rufus-tokyo.rb
authored
18
19
062b601 @jmettraux documented Tyrant and unix sockets, and initial doc about Rufus::Edo
authored
20 == Rufus::Edo
21
22 Note : Rufus::Tokyo focuses on leveraging Hirabayashi-san's C libraries via ruby-ffi, but the gem rufus-tokyo also contains Rufus::Edo which wraps the Tokyo Cabinet/Tyrant author's [native] C bindings :
23
24 http://github.com/jmettraux/rufus-tokyo/tree/master/lib/rufus/edo
25
26
6e5c50f @jmettraux extended README + rufus-tokyo.rb
authored
27 == usage
28
5fd2ac1 @jmettraux more doc and a stop spec ttservers
authored
29 hereafter TC references Tokyo Cabinet, while TT references Tokyo Tyrant.
30
2730e16 @jmettraux pointing to the rdoc
authored
31 the rdoc is at http://rufus.rubyforge.org/rufus-tokyo/
32
f01541b @jmettraux OpenModes mixin is back
authored
33
0a17b7d @jmettraux version [mis]match tracking
authored
34 == version [mis]match
35
6b1365f @jmettraux dropped selectively 'backward compatibility'
authored
36 this 'master' branch/version of rufus-tokyo works with
0a17b7d @jmettraux version [mis]match tracking
authored
37
98fe6e6 @jmettraux updated links (and --source http://gemcutter.org)
authored
38 ffi 0.3.1, 0.3.5, 0.4.0, 0.5.0, 0.5.1
ca6877a @jmettraux stating ffi version
authored
39
0a17b7d @jmettraux version [mis]match tracking
authored
40 ruby 1.8.6
9f1fb60 @jmettraux release 0.1.14
authored
41 ruby 1.9.1p129
42 jruby 1.1.6, 1.2.0, 1.3.1
98fe6e6 @jmettraux updated links (and --source http://gemcutter.org)
authored
43 ree 1.8.7 2009.10 (thanks to http://rvm.beginrescueend.com)
0a17b7d @jmettraux version [mis]match tracking
authored
44
84b1785 @jmettraux version numbers update
authored
45 TC 1.4.27 / 29 and TT 1.1.29 / 33
0a17b7d @jmettraux version [mis]match tracking
authored
46
84b1785 @jmettraux version numbers update
authored
47 tc-ruby 1.26 / 29 and tt-ruby 1.10 / 12 (Rufus::Edo)
fce3090 @jmettraux adapting to changes in tokyo cabinet 1.4.10
authored
48
0a17b7d @jmettraux version [mis]match tracking
authored
49
b0552c6 @jmettraux added doc about TOKYO_CABINET_LIB and TOKYO_TYRANT_LIB
authored
50 == Rufus::Tokyo : pointing to the right library
51
52 By default Rufus::Tokyo (the FFI side) searches for Tokyo Cabinet and Tyrant dynamic libraries under /usr/lib/, /usr/lib64/, /opt/local/lib/ and /usr/local/lib/
53
54 If you had to install Tokyo Cabinet (and Tokyo Tyrant) in another location, you can set the environment variables TOKYO_CABINET_LIB and TOKYO_TYRANT_LIB to point to the absolute path of the dynamic library, like in :
55
56 export TOKYO_CABINET_LIB = /home/toto/tc/libtokyocabinet.so
57 export TOKYO_TYRANT_LIB = /home/toto/tc/libtokyotyrant.so
58
59 So that your rufus-tokyo enabled Ruby application can see the libraries.
60
61
5fd2ac1 @jmettraux more doc and a stop spec ttservers
authored
62 === TC Abstract API
d0dbc5b @jmettraux missing require for Table + a bit of doc
authored
63
64 http://tokyocabinet.sourceforge.net/spex-en.html#tcadbapi
65
6e5c50f @jmettraux extended README + rufus-tokyo.rb
authored
66 to create a hash (file named 'data.tch')
67
68 require 'rubygems'
69 require 'rufus/tokyo'
70
71 db = Rufus::Tokyo::Cabinet.new('data.tch')
72
73 db['nada'] = 'surf'
74
75 p db['nada'] # => 'surf'
76 p db['lost'] # => nil
77
78 5000.times { |i| db[i.to_s] = "x" }
79
80 p db.inject { |r, (k, v)| k } # => 4999
81
82 db.close
83
84
5fd2ac1 @jmettraux more doc and a stop spec ttservers
authored
85 === TC Table API
d0dbc5b @jmettraux missing require for Table + a bit of doc
authored
86
87 http://tokyocabinet.sourceforge.net/spex-en.html#tctdbapi
88
89 require 'rubygems'
b88676e @jmettraux made sure it works even if the dystopia and/or tyrant libs are not pr…
authored
90 require 'rufus/tokyo'
1000557 @jmettraux bug : JRuby support back in
authored
91
29347f3 @jmettraux aligned Rufus::Edo::Cabinet#new on Rufus::Tokyo::Cabinet#new
authored
92 t = Rufus::Tokyo::Table.new('table.tct')
1000557 @jmettraux bug : JRuby support back in
authored
93
d0dbc5b @jmettraux missing require for Table + a bit of doc
authored
94 t['pk0'] = { 'name' => 'alfred', 'age' => '22' }
95 t['pk1'] = { 'name' => 'bob', 'age' => '18' }
96 t['pk2'] = { 'name' => 'charly', 'age' => '45' }
97 t['pk3'] = { 'name' => 'doug', 'age' => '77' }
98 t['pk4'] = { 'name' => 'ephrem', 'age' => '32' }
1000557 @jmettraux bug : JRuby support back in
authored
99
d0dbc5b @jmettraux missing require for Table + a bit of doc
authored
100 p t.query { |q|
36523be @jmettraux Table example in README slightly more verbose
authored
101 q.add_condition 'age', :numge, '32'
102 q.order_by 'age'
d0dbc5b @jmettraux missing require for Table + a bit of doc
authored
103 }
36523be @jmettraux Table example in README slightly more verbose
authored
104 # => [ {"name"=>"ephrem", :pk=>"pk4", "age"=>"32"},
105 # {"name"=>"charly", :pk=>"pk2", "age"=>"45"} ]
1000557 @jmettraux bug : JRuby support back in
authored
106
d0dbc5b @jmettraux missing require for Table + a bit of doc
authored
107 t.close
108
39297c1 @jmettraux release 0.1.6
authored
109 Note that the Tokyo Cabinet Table API does support transactions :
110
111 p t.size
112 # => 0
113
114 t.transaction do
115 t['pk0'] = { 'name' => 'alfred', 'age' => '22' }
116 t['pk1'] = { 'name' => 'bob', 'age' => '18' }
117 t.abort
118 end
119
120 p t.size
121 # => 0
122
123
5fd2ac1 @jmettraux more doc and a stop spec ttservers
authored
124 === TT remote db
125
126 http://tokyocabinet.sourceforge.net/tyrantdoc/
127
ddf90bf @jmettraux info about starting ttserver and link to TC / TT install page at ruote/
authored
128 to start a ttserver (backed by a hash), on the command line
129
130 ttserver -port 45001 data.tch
131
132
133 then, in Ruby :
134
5fd2ac1 @jmettraux more doc and a stop spec ttservers
authored
135 require 'rubygems'
1000557 @jmettraux bug : JRuby support back in
authored
136 require 'rufus/tokyo/tyrant'
5fd2ac1 @jmettraux more doc and a stop spec ttservers
authored
137
1000557 @jmettraux bug : JRuby support back in
authored
138 db = Rufus::Tokyo::Tyrant.new('localhost', 45001)
5fd2ac1 @jmettraux more doc and a stop spec ttservers
authored
139
140 db['nada'] = 'surf'
141
142 p db['nada'] # => 'surf'
143 p db['lost'] # => nil
144
145 db.close
146
f01541b @jmettraux OpenModes mixin is back
authored
147
39297c1 @jmettraux release 0.1.6
authored
148 Rufus::Tokyo::Tyrant instances have a #stat method :
149
150 puts db.stat.inject('') { |s, (k, v)| s << "#{k} => #{v}\n" }
151 # =>
152 # pid => 7566
153 # loadavg => 0.398438
154 # size => 528736
155 # rnum => 0
156 # time => 1234764065.305923
157 # sid => 898521513
158 # type => hash
159 # bigend => 0
160 # ru_sys => 3.398698
161 # version => 1.1.15
162 # ru_user => 2.155215
163 # ru_real => 3218.451152
164 # fd => 7
165
166
062b601 @jmettraux documented Tyrant and unix sockets, and initial doc about Rufus::Edo
authored
167 Note that it's also OK to make a Tokyo Tyrant server listen on a unix socket :
168
169 ttserver -host /tmp/ttsocket -port 0 data.tch
170
171 and then :
172
173 require 'rubygems'
174 require 'rufus/tokyo/tyrant'
175 db = Rufus::Tokyo::Tyrant.new('/tmp/ttsocket')
176 db['a'] = 'alpha'
177 db.close
178
179
5fd2ac1 @jmettraux more doc and a stop spec ttservers
authored
180 === TT remote table
181
ddf90bf @jmettraux info about starting ttserver and link to TC / TT install page at ruote/
authored
182 to start a ttserver (backed by a table), on the command line :
183
1000557 @jmettraux bug : JRuby support back in
authored
184 ttserver -port 45002 data.tct
ddf90bf @jmettraux info about starting ttserver and link to TC / TT install page at ruote/
authored
185
186
187 then, in Ruby, much like a local table :
5fd2ac1 @jmettraux more doc and a stop spec ttservers
authored
188
189 require 'rubygems'
1000557 @jmettraux bug : JRuby support back in
authored
190 require 'rufus/tokyo/tyrant'
191
192 t = Rufus::Tokyo::TyrantTable.new('localhost', 45002)
193
5fd2ac1 @jmettraux more doc and a stop spec ttservers
authored
194 t['pk0'] = { 'name' => 'alfred', 'age' => '22' }
195 t['pk1'] = { 'name' => 'bob', 'age' => '18' }
196 t['pk2'] = { 'name' => 'charly', 'age' => '45' }
197 t['pk3'] = { 'name' => 'doug', 'age' => '77' }
198 t['pk4'] = { 'name' => 'ephrem', 'age' => '32' }
1000557 @jmettraux bug : JRuby support back in
authored
199
5fd2ac1 @jmettraux more doc and a stop spec ttservers
authored
200 p t.query { |q|
201 q.add_condition 'age', :numge, '32'
202 q.order_by 'age'
203 }
204 # => [ {"name"=>"ephrem", :pk=>"pk4", "age"=>"32"},
205 # {"name"=>"charly", :pk=>"pk2", "age"=>"45"} ]
1000557 @jmettraux bug : JRuby support back in
authored
206
5fd2ac1 @jmettraux more doc and a stop spec ttservers
authored
207 t.close
208
d0dbc5b @jmettraux missing require for Table + a bit of doc
authored
209
39297c1 @jmettraux release 0.1.6
authored
210 Rufus::Tokyo::TyrantTable instances have a #stat method :
211
212 puts t.stat.inject('') { |s, (k, v)| s << "#{k} => #{v}\n" }
213 # =>
214 # pid => 7569
215 # loadavg => 0.295410
216 # size => 935792
217 # rnum => 0
218 # time => 1234764228.942014
219 # sid => 1027604232
220 # type => table
221 # bigend => 0
222 # ru_sys => 5.966750
223 # version => 1.1.15
224 # ru_user => 2.601947
225 # ru_real => 3382.084479
226 # fd => 10
227
228
062b601 @jmettraux documented Tyrant and unix sockets, and initial doc about Rufus::Edo
authored
229 Note that it's also OK to make a Tokyo Tyrant server listen on a unix socket :
230
231 ttserver -host /tmp/tttsocket -port 0 data.tct
232
233 and then :
234
235 require 'rubygems'
236 require 'rufus/tokyo/tyrant'
237 t = Rufus::Tokyo::TyrantTable.new('/tmp/tttsocket')
238 t['customer0'] = { 'name' => 'Heike no Kyomori', 'age' => '75' }
239 t.close
240
241
39297c1 @jmettraux release 0.1.6
authored
242 == rdoc
243
42ec671 @jmettraux release 0.1.0
authored
244 more in the rdoc
245
9f1fb60 @jmettraux release 0.1.14
authored
246 * http://rufus.rubyforge.org/rufus-tokyo/
247 * http://rufus.rubyforge.org/rufus-tokyo/classes/Rufus/Tokyo/Cabinet.html
248 * http://rufus.rubyforge.org/rufus-tokyo/classes/Rufus/Tokyo/Table.html
249 * http://rufus.rubyforge.org/rufus-tokyo/classes/Rufus/Tokyo/Tyrant.html
250 * http://rufus.rubyforge.org/rufus-tokyo/classes/Rufus/Tokyo/TyrantTable.html
42ec671 @jmettraux release 0.1.0
authored
251
ddf90bf @jmettraux info about starting ttserver and link to TC / TT install page at ruote/
authored
252 don't hesitate to "man ttserver" on the command line.
253
42ec671 @jmettraux release 0.1.0
authored
254 or directly in the source
255
9f1fb60 @jmettraux release 0.1.14
authored
256 * http://github.com/jmettraux/rufus-tokyo/blob/master/lib/rufus/tokyo/cabinet/abstract.rb
257 * http://github.com/jmettraux/rufus-tokyo/blob/master/lib/rufus/tokyo/cabinet/table.rb
258 * http://github.com/jmettraux/rufus-tokyo/blob/master/lib/rufus/tokyo/tyrant/abstract.rb
259 * http://github.com/jmettraux/rufus-tokyo/blob/master/lib/rufus/tokyo/tyrant/table.rb
42ec671 @jmettraux release 0.1.0
authored
260
261
ddf90bf @jmettraux info about starting ttserver and link to TC / TT install page at ruote/
authored
262 == Tokyo Cabinet / Tyrant install
5fd2ac1 @jmettraux more doc and a stop spec ttservers
authored
263
3673349 @jmettraux dropped #tabbed_put for cabinet and tyrant tables, simplification.
authored
264 a compilation of notes is available at :
5fd2ac1 @jmettraux more doc and a stop spec ttservers
authored
265
ddf90bf @jmettraux info about starting ttserver and link to TC / TT install page at ruote/
authored
266 http://openwferu.rubyforge.org/tokyo.html
5fd2ac1 @jmettraux more doc and a stop spec ttservers
authored
267
268
6e5c50f @jmettraux extended README + rufus-tokyo.rb
authored
269 == dependencies
270
3673349 @jmettraux dropped #tabbed_put for cabinet and tyrant tables, simplification.
authored
271 the ruby gem 'ffi'
6e5c50f @jmettraux extended README + rufus-tokyo.rb
authored
272
273
274 == mailing list
275
3673349 @jmettraux dropped #tabbed_put for cabinet and tyrant tables, simplification.
authored
276 On the rufus-ruby list :
6e5c50f @jmettraux extended README + rufus-tokyo.rb
authored
277
5fd2ac1 @jmettraux more doc and a stop spec ttservers
authored
278 http://groups.google.com/group/rufus-ruby
6e5c50f @jmettraux extended README + rufus-tokyo.rb
authored
279
98fe6e6 @jmettraux updated links (and --source http://gemcutter.org)
authored
280 Note : Flinn Mueller started an english speaking mailing list for TC / TT / TD
6b1365f @jmettraux dropped selectively 'backward compatibility'
authored
281
282 http://groups.google.com/group/tokyocabinet-users
283
6e5c50f @jmettraux extended README + rufus-tokyo.rb
authored
284
285 == issue tracker
286
9a588ea @jmettraux issue tracker is now on github
authored
287 http://github.com/jmettraux/rufus-tokyo/issues/
6e5c50f @jmettraux extended README + rufus-tokyo.rb
authored
288
289
290 == irc
291
292 irc.freenode.net #ruote
293
294
295 == source
296
297 http://github.com/jmettraux/rufus-tokyo
298
5fd2ac1 @jmettraux more doc and a stop spec ttservers
authored
299 git clone git://github.com/jmettraux/rufus-tokyo.git
6e5c50f @jmettraux extended README + rufus-tokyo.rb
authored
300
301
302 == credits
303
0489e88 @jmettraux dried hash-like methods to hmethods.rb
authored
304 many thanks to the author of Tokyo Cabinet, Mikio Hirabayashi, and to the authors of ruby-ffi
6e5c50f @jmettraux extended README + rufus-tokyo.rb
authored
305
98fe6e6 @jmettraux updated links (and --source http://gemcutter.org)
authored
306 * http://1978th.net/tokyocabinet/
307 * http://1978th.net/tokyotyrant/
308 * http://1978th.net/tokyodystopia/
309
310 * http://wiki.github.com/ffi/ffi
6e5c50f @jmettraux extended README + rufus-tokyo.rb
authored
311
7d8c69e @copiousfreetime adding atrributesion
copiousfreetime authored
312 dystopia interface developed with and sponsored by Seven Scale <http://sevenscale.com/>,
ac365b1 @jmettraux resolved merge issues
authored
313 creators of Open Syslog.
6e5c50f @jmettraux extended README + rufus-tokyo.rb
authored
314
98fe6e6 @jmettraux updated links (and --source http://gemcutter.org)
authored
315
1b719a4 @jmettraux two heads
authored
316 == authors
6e5c50f @jmettraux extended README + rufus-tokyo.rb
authored
317
9f1fb60 @jmettraux release 0.1.14
authored
318 * John Mettraux, jmettraux@gmail.com, http://jmettraux.wordpress.com
319 * Zev Blut, http://www.iknow.co.jp/users/zev
ac365b1 @jmettraux resolved merge issues
authored
320 * Jeremy Hinegardner http://github.com/copiousfreetime (Tokyo Dystopia)
98fe6e6 @jmettraux updated links (and --source http://gemcutter.org)
authored
321 * James Edward Gray II http://blog.grayproductions.net/
322
6e5c50f @jmettraux extended README + rufus-tokyo.rb
authored
323
324 == the rest of Rufus
325
326 http://rufus.rubyforge.org
327
328
329 == license
330
331 MIT
2a5b11b @jmettraux initial commit
authored
332
Something went wrong with that request. Please try again.