actsasflinn-ruby-tokyotyrant 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +12 -5
- data/Rakefile +27 -2
- data/benchmarks/bulk_db.rb +2 -2
- data/benchmarks/bulk_table.rb +4 -2
- data/benchmarks/db.rb +4 -4
- data/benchmarks/table.rb +3 -3
- data/spec/start_tyrants.sh +25 -0
- data/spec/stop_tyrants.sh +9 -0
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
3
|
This is a c extension for Ruby to access TokyoTyrant databases. It currently supports key/value, table databases and table queries.
|
4
4
|
|
5
|
+
== Install
|
6
|
+
|
7
|
+
# install tokyocabint and tokyotyrant
|
8
|
+
# after installing tc and tt on linux I had to /sbin/ldconfig (as root)
|
9
|
+
gem sources -a http://gems.github.com
|
10
|
+
sudo gem install actsasflinn-ruby-tokyotyrant
|
11
|
+
|
5
12
|
== Performance
|
6
13
|
|
7
14
|
This is not in production but the initial benchmarks are very interesting. Results look closer to the memcached gem than any other tyrant client I've seen for Ruby.
|
@@ -39,21 +46,21 @@ This is not in production but the initial benchmarks are very interesting. Resul
|
|
39
46
|
require 'tokyo_tyrant'
|
40
47
|
t = TokyoTyrant::Table.new('127.0.0.1', 1978)
|
41
48
|
|
42
|
-
t['bar'] = {
|
43
|
-
t['bar']
|
49
|
+
t['bar'] = { :baz => 'box' } # => { :baz => 'box' }
|
50
|
+
t['bar'] # => { :baz => 'box' }
|
44
51
|
|
45
52
|
t.each{ |k,v| puts [k, v].inspect }
|
46
|
-
# ["bar", {
|
53
|
+
# ["bar", {:baz=>"box"}]
|
47
54
|
# => nil
|
48
55
|
|
49
56
|
# bulk operations
|
50
57
|
h = {}
|
51
58
|
100.times do |i|
|
52
|
-
h[i] = {
|
59
|
+
h[i] = { :name => 'Pat', :sex => i % 2 > 0 ? 'male' : 'female' }
|
53
60
|
end
|
54
61
|
t.mput(h)
|
55
62
|
t.mget(0..3)
|
56
|
-
# => {"0"=>{
|
63
|
+
# => {"0"=>{:name=>"Pat", :sex=>"female"}, "1"=>{:name=>"Pat", :sex=>"male"}, "2"=>{:name=>"Pat", :sex=>"female"}, "3"=>{:name=>"Pat", :sex=>"male"}}
|
57
64
|
|
58
65
|
=== Table Query
|
59
66
|
|
data/Rakefile
CHANGED
@@ -18,8 +18,33 @@ task :default => [ :spec ]
|
|
18
18
|
|
19
19
|
CLEAN.include('pkg', 'tmp')
|
20
20
|
|
21
|
-
gemspec =
|
22
|
-
|
21
|
+
gemspec = Gem::Specification.new do |s|
|
22
|
+
s.name = 'ruby-tokyotyrant'
|
23
|
+
s.version = '0.1.4'
|
24
|
+
s.authors = [ 'Flinn' ]
|
25
|
+
s.email = 'flinn@actsasflinn.com'
|
26
|
+
s.homepage = 'http://github.com/actsasflinn/ruby-tokyotyrant/'
|
27
|
+
s.platform = Gem::Platform::RUBY
|
28
|
+
s.summary = 'A C based TokyoTyrant Ruby binding'
|
29
|
+
s.require_path = 'ext'
|
30
|
+
s.test_file = 'spec/spec.rb'
|
31
|
+
s.has_rdoc = true
|
32
|
+
s.extra_rdoc_files = %w{ README.rdoc }
|
33
|
+
|
34
|
+
s.files = ['COPYING',
|
35
|
+
'Rakefile',
|
36
|
+
'README.rdoc'] +
|
37
|
+
Dir['ext/**/*'] +
|
38
|
+
Dir['spec/**/*'] +
|
39
|
+
Dir['benchmarks/**/*']
|
40
|
+
s.extensions << "ext/extconf.rb"
|
41
|
+
end
|
42
|
+
|
43
|
+
task :gemspec do
|
44
|
+
File.open('ruby-tokyotyrant.gemspec', 'w') do |f|
|
45
|
+
f.write(gemspec.to_ruby)
|
46
|
+
end
|
47
|
+
end
|
23
48
|
|
24
49
|
Rake::GemPackageTask.new(gemspec) do |pkg|
|
25
50
|
pkg.need_tar = true
|
data/benchmarks/bulk_db.rb
CHANGED
@@ -18,7 +18,7 @@ end
|
|
18
18
|
require 'tokyotyrant'
|
19
19
|
|
20
20
|
rdb = TokyoTyrant::RDB::new
|
21
|
-
rdb.open("127.0.0.1",
|
21
|
+
rdb.open("127.0.0.1", 45000)
|
22
22
|
rdb.clear
|
23
23
|
nothing = nil
|
24
24
|
|
@@ -36,7 +36,7 @@ Benchmark.benchmark(' ' * 20 + Benchmark::Tms::CAPTION, 20) do |b|
|
|
36
36
|
end
|
37
37
|
|
38
38
|
require 'tokyo_tyrant'
|
39
|
-
t = TokyoTyrant::DB.new('127.0.0.1',
|
39
|
+
t = TokyoTyrant::DB.new('127.0.0.1', 45000)
|
40
40
|
t.clear
|
41
41
|
nothing = nil
|
42
42
|
|
data/benchmarks/bulk_table.rb
CHANGED
@@ -3,6 +3,8 @@ require 'rubygems'
|
|
3
3
|
require 'faker'
|
4
4
|
require 'date'
|
5
5
|
|
6
|
+
puts "Tokyo Tyrant Bulk Table Operations Benchmark"
|
7
|
+
|
6
8
|
$year = (1909 .. 2009).to_a
|
7
9
|
$month = (1..12).to_a
|
8
10
|
$day = (1..28).to_a # not bothering with month diffs
|
@@ -32,7 +34,7 @@ data = {}
|
|
32
34
|
end
|
33
35
|
|
34
36
|
require 'tokyo_tyrant'
|
35
|
-
t = TokyoTyrant::Table.new('127.0.0.1',
|
37
|
+
t = TokyoTyrant::Table.new('127.0.0.1', 45001)
|
36
38
|
t.clear
|
37
39
|
|
38
40
|
2.times { puts }
|
@@ -51,7 +53,7 @@ end
|
|
51
53
|
require 'tokyotyrant'
|
52
54
|
|
53
55
|
rdb = TokyoTyrant::RDB::new
|
54
|
-
rdb.open("127.0.0.1",
|
56
|
+
rdb.open("127.0.0.1", 45001)
|
55
57
|
rdb.clear
|
56
58
|
|
57
59
|
2.times { puts }
|
data/benchmarks/db.rb
CHANGED
@@ -10,7 +10,7 @@ end
|
|
10
10
|
|
11
11
|
require 'rufus/tokyo/tyrant'
|
12
12
|
|
13
|
-
r = Rufus::Tokyo::Tyrant.new('127.0.0.1',
|
13
|
+
r = Rufus::Tokyo::Tyrant.new('127.0.0.1', 45000)
|
14
14
|
r.clear
|
15
15
|
|
16
16
|
2.times { puts }
|
@@ -29,7 +29,7 @@ end
|
|
29
29
|
require 'tokyotyrant'
|
30
30
|
|
31
31
|
rdb = TokyoTyrant::RDB::new
|
32
|
-
rdb.open("127.0.0.1",
|
32
|
+
rdb.open("127.0.0.1", 45000)
|
33
33
|
rdb.clear
|
34
34
|
|
35
35
|
2.times { puts }
|
@@ -46,7 +46,7 @@ Benchmark.benchmark(' ' * 20 + Benchmark::Tms::CAPTION, 20) do |b|
|
|
46
46
|
end
|
47
47
|
|
48
48
|
require 'tokyo_tyrant'
|
49
|
-
t = TokyoTyrant::DB.new('127.0.0.1',
|
49
|
+
t = TokyoTyrant::DB.new('127.0.0.1', 45000)
|
50
50
|
t.clear
|
51
51
|
|
52
52
|
2.times { puts }
|
@@ -63,7 +63,7 @@ Benchmark.benchmark(' ' * 20 + Benchmark::Tms::CAPTION, 20) do |b|
|
|
63
63
|
end
|
64
64
|
|
65
65
|
require 'memcached'
|
66
|
-
m = Memcached.new('127.0.0.1:
|
66
|
+
m = Memcached.new('127.0.0.1:45000')
|
67
67
|
m.flush
|
68
68
|
|
69
69
|
2.times { puts }
|
data/benchmarks/table.rb
CHANGED
@@ -62,7 +62,7 @@ data1 = data.collect { |e|
|
|
62
62
|
|
63
63
|
require 'rufus/tokyo/tyrant'
|
64
64
|
|
65
|
-
r = Rufus::Tokyo::TyrantTable.new('127.0.0.1',
|
65
|
+
r = Rufus::Tokyo::TyrantTable.new('127.0.0.1', 45001)
|
66
66
|
r.clear
|
67
67
|
|
68
68
|
2.times { puts }
|
@@ -81,7 +81,7 @@ end
|
|
81
81
|
require 'tokyotyrant'
|
82
82
|
|
83
83
|
rdb = TokyoTyrant::RDBTBL::new
|
84
|
-
rdb.open("127.0.0.1",
|
84
|
+
rdb.open("127.0.0.1", 45001)
|
85
85
|
rdb.clear
|
86
86
|
|
87
87
|
2.times { puts }
|
@@ -98,7 +98,7 @@ Benchmark.benchmark(' ' * 20 + Benchmark::Tms::CAPTION, 20) do |b|
|
|
98
98
|
end
|
99
99
|
|
100
100
|
require 'tokyo_tyrant'
|
101
|
-
t = TokyoTyrant::Table.new('127.0.0.1',
|
101
|
+
t = TokyoTyrant::Table.new('127.0.0.1', 45001)
|
102
102
|
t.clear
|
103
103
|
|
104
104
|
2.times { puts }
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
#
|
4
|
+
# starting the tt servers (standard + table)
|
5
|
+
#
|
6
|
+
|
7
|
+
TMP=`pwd`/tmp
|
8
|
+
# so that tt doesn't complain about relative paths...
|
9
|
+
|
10
|
+
[ -d $TMP ] || mkdir $TMP
|
11
|
+
|
12
|
+
ttserver \
|
13
|
+
-dmn \
|
14
|
+
-port 45000 \
|
15
|
+
-pid $TMP/t_spec.pid -rts $TMP/t_spec.rts \
|
16
|
+
-log $TMP/t.log \
|
17
|
+
$TMP/tyrant.tch
|
18
|
+
|
19
|
+
ttserver \
|
20
|
+
-dmn \
|
21
|
+
-port 45001 \
|
22
|
+
-pid $TMP/tt_spec.pid -rts $TMP/tt_spec.rts \
|
23
|
+
-log $TMP/tt.log \
|
24
|
+
$TMP/tyrant_table.tct
|
25
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actsasflinn-ruby-tokyotyrant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flinn
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-04-
|
12
|
+
date: 2009-04-05 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -39,8 +39,8 @@ files:
|
|
39
39
|
- spec/plu_db.rb
|
40
40
|
- spec/spec.rb
|
41
41
|
- spec/spec_base.rb
|
42
|
-
- spec/
|
43
|
-
- spec/
|
42
|
+
- spec/start_tyrants.sh
|
43
|
+
- spec/stop_tyrants.sh
|
44
44
|
- spec/tokyo_tyrant_query_spec.rb
|
45
45
|
- spec/tokyo_tyrant_spec.rb
|
46
46
|
- spec/tokyo_tyrant_table_spec.rb
|