actsasflinn-ruby-tokyotyrant 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.rdoc +82 -0
  2. data/spec/spec.rb +1 -0
  3. metadata +53 -0
data/README.rdoc ADDED
@@ -0,0 +1,82 @@
1
+ = TokyoTyrant Ruby Client
2
+
3
+ This is a c extension for Ruby to access TokyoTyrant databases. It currently supports key/value, table databases and table queries.
4
+
5
+ == Performance
6
+
7
+ 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.
8
+
9
+ * Key/Value Store: http://gist.github.com/75212
10
+ * Table Store: http://gist.github.com/74116
11
+ * Bulk Operations: http://gist.github.com/83194
12
+ * Bulk Table Operations: http://gist.github.com/87215
13
+
14
+ == Example
15
+
16
+ === Hash DB
17
+
18
+ # start tyrant like so:
19
+ # ttserver example.tch
20
+
21
+ require 'tokyo_tyrant'
22
+ db = TokyoTyrant::DB.new('127.0.0.1', 1978)
23
+
24
+ db['foo'] = 'Bar' # => "Bar"
25
+ db['foo'] # => "Bar"
26
+
27
+ db.each{ |k,v| puts [k, v].inspect }
28
+ # ["foo", "Bar"]
29
+ # => nil
30
+
31
+ db.mput("1"=>"number_1", "2"=>"number_2", "3"=>"number_3", "4"=>"number_4", "5"=>"number_5")
32
+ db.mget(1..3) # => {"1"=>"number_1", "2"=>"number_2", "3"=>"number_3"}
33
+
34
+ === Table DB
35
+
36
+ # start tyrant like so:
37
+ # ttserver example.tct
38
+
39
+ require 'tokyo_tyrant'
40
+ t = TokyoTyrant::Table.new('127.0.0.1', 1978)
41
+
42
+ t['bar'] = { 'baz' => 'box' } # => { 'baz' => 'box' }
43
+ t['bar'] # => { 'baz' => 'box' }
44
+
45
+ t.each{ |k,v| puts [k, v].inspect }
46
+ # ["bar", {"baz"=>"box"}]
47
+ # => nil
48
+
49
+ # bulk operations
50
+ h = {}
51
+ 100.times do |i|
52
+ h[i] = { 'name' => 'Pat', 'sex' => i % 2 > 0 ? 'male' : 'female' }
53
+ end
54
+ t.mput(h)
55
+ t.mget(0..3)
56
+ # => {"0"=>{"name"=>"Pat", "sex"=>"female"}, "1"=>{"name"=>"Pat", "sex"=>"male"}, "2"=>{"name"=>"Pat", "sex"=>"female"}, "3"=>{"name"=>"Pat", "sex"=>"male"}}
57
+
58
+ === Table Query
59
+
60
+ require 'tokyo_tyrant'
61
+ t = TokyoTyrant::Table.new('127.0.0.1', 1978)
62
+
63
+ 100.times do |i|
64
+ t[i] = { 'name' => "Pat #{i}", 'sex' => i % 2 > 0 ? 'male' : 'female' }
65
+ end
66
+
67
+ q = t.query
68
+ q.condition('sex', :streq, 'male')
69
+ q.limit(5)
70
+ # Get a list of IDs
71
+ ids = q.search
72
+ # => ["1", "3", "5", "7", "9"]
73
+ q.order_by(:name, :strdesc)
74
+ ids = q.search
75
+ # => ["99", "97", "95", "93", "91"]
76
+ # Get the actual records
77
+ q.get
78
+ # => [{:__id=>"99", :sex=>"male", :name=>"Pat 99"}, {:__id=>"97", :sex=>"male", :name=>"Pat 97"}, {:__id=>"95", :sex=>"male", :name=>"Pat 95"}, {:__id=>"93", :sex=>"male", :name=>"Pat 93"}, {:__id=>"91", :sex=>"male", :name=>"Pat 91"}]
79
+
80
+ == TODO
81
+ * implement get_reverse for has_value?
82
+ * fix up and test extensions
data/spec/spec.rb ADDED
@@ -0,0 +1 @@
1
+ Dir["#{File.dirname(__FILE__)}/*_spec.rb"].each { |path| load(path) }
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: actsasflinn-ruby-tokyotyrant
3
+ version: !ruby/object:Gem::Version
4
+ version: "0.1"
5
+ platform: ruby
6
+ authors:
7
+ - Flinn
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-04-01 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: flinn@actsasflinn.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ files:
25
+ - README.rdoc
26
+ has_rdoc: true
27
+ homepage: http://github.com/actsasflinn/ruby-tokyotyrant/
28
+ post_install_message:
29
+ rdoc_options: []
30
+
31
+ require_paths:
32
+ - lib
33
+ required_ruby_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: "0"
38
+ version:
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ requirements: []
46
+
47
+ rubyforge_project:
48
+ rubygems_version: 1.2.0
49
+ signing_key:
50
+ specification_version: 2
51
+ summary: A C based TokyoTyrant Ruby binding
52
+ test_files:
53
+ - spec/spec.rb