Class: FastCache::Memcache::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/fastcache/memcache/node.rb

Constant Summary collapse

CONNECT_TIMEOUT =
0.25
RETRY_DELAY =
10.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port) ⇒ Node

Returns a new instance of Node.



11
12
13
14
15
16
17
18
# File 'lib/fastcache/memcache/node.rb', line 11

def initialize(host, port)
  @host = host
  @port = port
  @weight = 1
  @status = :disconnected
  @socket = nil
  @retry = nil
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



5
6
7
# File 'lib/fastcache/memcache/node.rb', line 5

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



5
6
7
# File 'lib/fastcache/memcache/node.rb', line 5

def port
  @port
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/fastcache/memcache/node.rb', line 5

def status
  @status
end

#weightObject

Returns the value of attribute weight.



6
7
8
# File 'lib/fastcache/memcache/node.rb', line 6

def weight
  @weight
end

Instance Method Details

#closeObject



32
33
34
35
# File 'lib/fastcache/memcache/node.rb', line 32

def close
  socket.close
  @socket = nil
end

#connectObject



37
38
39
# File 'lib/fastcache/memcache/node.rb', line 37

def connect
  socket
end

#getsObject



28
29
30
# File 'lib/fastcache/memcache/node.rb', line 28

def gets
  socket.gets
end

#read(*a) ⇒ Object



20
21
22
# File 'lib/fastcache/memcache/node.rb', line 20

def read(*a)
  socket.read(*a)
end

#write(data) ⇒ Object



24
25
26
# File 'lib/fastcache/memcache/node.rb', line 24

def write(data)
  socket.write(data)
end