Class: TCPTimeoutSocket
- Inherits:
-
Object
show all
- Defined in:
- lib/memcache.rb
Overview
TCPSocket facade class which implements timeouts.
Instance Method Summary
collapse
Constructor Details
#initialize(host, port, timeout) ⇒ TCPTimeoutSocket
Returns a new instance of TCPTimeoutSocket.
1065
1066
1067
1068
1069
1070
|
# File 'lib/memcache.rb', line 1065
def initialize(host, port, timeout)
MemCacheTimer.timeout(MemCache::Server::CONNECT_TIMEOUT) do
@sock = TCPSocket.new(host, port)
@len = timeout
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args) ⇒ Object
1094
1095
1096
|
# File 'lib/memcache.rb', line 1094
def method_missing(meth, *args)
@sock.__send__(meth, *args)
end
|
Instance Method Details
#_socket ⇒ Object
1090
1091
1092
|
# File 'lib/memcache.rb', line 1090
def _socket
@sock
end
|
#close ⇒ Object
1102
1103
1104
|
# File 'lib/memcache.rb', line 1102
def close
@sock.close
end
|
#closed? ⇒ Boolean
1098
1099
1100
|
# File 'lib/memcache.rb', line 1098
def closed?
@sock.closed?
end
|
#gets(*args) ⇒ Object
1078
1079
1080
1081
1082
|
# File 'lib/memcache.rb', line 1078
def gets(*args)
MemCacheTimer.timeout(@len) do
@sock.gets(*args)
end
end
|
#read(*args) ⇒ Object
1084
1085
1086
1087
1088
|
# File 'lib/memcache.rb', line 1084
def read(*args)
MemCacheTimer.timeout(@len) do
@sock.read(*args)
end
end
|
#write(*args) ⇒ Object
1072
1073
1074
1075
1076
|
# File 'lib/memcache.rb', line 1072
def write(*args)
MemCacheTimer.timeout(@len) do
@sock.write(*args)
end
end
|