Class: Rufus::Tokyo::Tyrant
- Includes:
- Ext, TyrantCommons
- Defined in:
- lib/rufus/tokyo/tyrant/abstract.rb
Overview
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Attributes included from HashMethods
Instance Method Summary collapse
-
#copy(target_path) ⇒ Object
isn’t that a bit dangerous ? it creates a file on the server…
-
#initialize(host, port = 0) ⇒ Tyrant
constructor
Connects to a given Tokyo Tyrant server.
-
#lib ⇒ Object
Using the tyrant lib.
Methods included from Ext
Methods included from TyrantCommons
Methods inherited from Cabinet
#[]=, #clear, #close, #compact_copy, #defrag, #delete, #delete_keys_with_prefix, #get4, #incr, #keys, #ldelete, #lget, #merge!, new_hash, new_tree, open, #path, #putcat, #putdup, #putkeep, #size, #sync, #tranabort, #tranbegin, #trancommit, #weight
Methods included from Outlen
Methods included from Transactions
Methods included from HashMethods
#[], #default, #default=, #each, #merge, #merge!, #to_a, #to_h, #values
Constructor Details
#initialize(host, port = 0) ⇒ Tyrant
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)
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 |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
43 44 45 |
# File 'lib/rufus/tokyo/tyrant/abstract.rb', line 43 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
43 44 45 |
# File 'lib/rufus/tokyo/tyrant/abstract.rb', line 43 def port @port end |
Instance Method Details
#copy(target_path) ⇒ Object
isn’t that a bit dangerous ? it creates a file on the server…
DISABLED.
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 ⇒ Object
Using the tyrant lib
88 89 90 91 |
# File 'lib/rufus/tokyo/tyrant/abstract.rb', line 88 def lib TyrantLib end |