Class: Rufus::Tokyo::Tyrant

Connecting to a ‘classic’ tyrant server remotely

  require 'rufus/tokyo/tyrant'
  t = Rufus::Tokyo::Tyrant.new('127.0.0.1', 44001)
  t['toto'] = 'blah blah'
  t['toto'] # => 'blah blah'

Attributes

Instance Attributes

host [R] public

Returns the value of attribute host.

port [R] public

Returns the value of attribute port.

Constructor Summary

public initialize(host, port = 0)

Connects to a given Tokyo Tyrant server.

Note that if the port is not specified, the host parameter is expected to hold the path to a unix socket (not a TCP socket).

(You can start a unix socket listening Tyrant with :

   ttserver -host /tmp/tyrant_socket -port 0 data.tch

 and then connect to it with rufus-tokyo via :

   require 'rufus/tokyo/tyrant'
   db = Rufus::Tokyo::Tyrant.new('/tmp/tyrant_socket')
   db['a'] = 'alpha'
   db.close

)

To connect to a classic TCP bound Tyrant (port 44001) :

  t = Rufus::Tokyo::Tyrant.new('127.0.0.1', 44001)
[View source]


66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/rufus/tokyo/tyrant/abstract.rb', line 66

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 table, " +
      "use Rufus::Tokyo::TyrantTable instead to access it.")
  end
end

Public Visibility

Public Class Methods Inherited from Rufus::Tokyo::Cabinet

new_hash, new_tree, open

Public Instance Method Summary

#copy(target_path)

isn’t that a bit dangerous ? it creates a file on the server.

#lib

Using the tyrant lib.

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

compute_ext_opts, stat

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

ext

Public Instance Method Details

copy

public copy(target_path)

isn’t that a bit dangerous ? it creates a file on the server…

DISABLED.

[View source]


97
98
99
100
101
# File 'lib/rufus/tokyo/tyrant/abstract.rb', line 97

def copy (target_path)

  #@db.copy(target_path)
  raise 'not allowed to create files on the server'
end

lib

public lib

Using the tyrant lib

[View source]


88
89
90
91
# File 'lib/rufus/tokyo/tyrant/abstract.rb', line 88

def lib

  TyrantLib
end
Generated on Friday, September 18 2009 at 10:35:43 AM by YARD 0.2.3.5 (ruby-1.8.7).