Class: Rufus::Tokyo::TyrantTable

A Tokyo Cabinet table, but remote…

  require 'rufus/tokyo/tyrant'
  t = Rufus::Tokyo::Tyrant.new('127.0.0.1', 44001)
  t['toto'] = { 'name' => 'toto the first', 'age' => '34' }
  t['toto']
    # => { 'name' => 'toto the first', 'age' => '34' }

Most of the methods of this TyrantTable class are defined in the parent class Rufus::Tokyo::Table.

Attributes

Instance Attributes

host [R] public

Returns the value of attribute host.

port [R] public

Returns the value of attribute port.

Constants Inherited from Rufus::Tokyo::Table

INDEX_TYPES, META_TYPES

Constructor Summary

public initialize(host, port = 0)

Connects to the Tyrant table listening at the given host and port.

You start such a Tyrant with :

  ttserver -port 44502 data.tct

and then :

  require 'rufus/tokyo/tyrant'
  t = Rufus::Tokyo::TyrantTable.new('127.0.0.1', 44502)
  t['client0'] = { 'name' => 'Heike no Kyomori', 'country' => 'jp' }
  t.close

You can start a Tokyo Tyrant and make it listen to a unix socket (not TCP) with :

  ttserver -host /tmp/table_socket -port 0 data.tct

then :

  require 'rufus/tokyo/tyrant'
  t = Rufus::Tokyo::TyrantTable.new('/tmp/table_socket')
  t['client0'] = { 'name' => 'Theodore Roosevelt', 'country' => 'usa' }
  t.close
[View source]


78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/rufus/tokyo/tyrant/table.rb', line 78

def initialize (host, port=0)

  @db = lib.tcrdbnew

  @host = host
  @port = port

  (lib.tcrdbopen(@db, host, port) == 1) ||
    raise(TokyoError.new("couldn't connect to tyrant at #{host}:#{port}"))

  if self.stat['type'] != 'table'

    self.close

    raise ArgumentError.new(
      "tyrant at #{host}:#{port} is a not table, " +
      "use Rufus::Tokyo::Tyrant instead to access it.")
  end
end

Public Visibility

Public Instance Method Summary

#abort
#lib

using the cabinet lib.

#tranabort
#tranbegin
#trancommit
#transaction

Public Instance Methods Included from Rufus::Tokyo::TyrantCommons

compute_ext_opts, stat

Public Instance Methods Included from Rufus::Tokyo::Outlen

outlen_op

Public Instance Methods Included from Rufus::Tokyo::Ext

ext

Public Instance Method Details

abort

public abort
[View source]


108
109
110
# File 'lib/rufus/tokyo/tyrant/table.rb', line 108

def abort 
  raise_transaction_nme('abort')
end

lib

public lib

using the cabinet lib

[View source]


101
102
103
# File 'lib/rufus/tokyo/tyrant/table.rb', line 101

def lib
  TyrantLib
end

tranabort

public tranabort
[View source]


117
118
119
# File 'lib/rufus/tokyo/tyrant/table.rb', line 117

def tranabort 
  raise_transaction_nme('tranabort')
end

tranbegin

public tranbegin
[View source]


111
112
113
# File 'lib/rufus/tokyo/tyrant/table.rb', line 111

def tranbegin 
  raise_transaction_nme('tranbegin')
end

trancommit

public trancommit
[View source]


114
115
116
# File 'lib/rufus/tokyo/tyrant/table.rb', line 114

def trancommit 
  raise_transaction_nme('trancommit')
end

transaction

public transaction
[View source]


105
106
107
# File 'lib/rufus/tokyo/tyrant/table.rb', line 105

def transaction 
  raise_transaction_nme('transaction')
end
Generated on Friday, September 18 2009 at 10:35:40 AM by YARD 0.2.3.5 (ruby-1.8.7).