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.
876
877
878
879
880
881
|
# File 'lib/memcache.rb', line 876
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
905
906
907
|
# File 'lib/memcache.rb', line 905
def method_missing(meth, *args)
@sock.__send__(meth, *args)
end
|
Instance Method Details
#_socket ⇒ Object
901
902
903
|
# File 'lib/memcache.rb', line 901
def _socket
@sock
end
|
#close ⇒ Object
913
914
915
|
# File 'lib/memcache.rb', line 913
def close
@sock.close
end
|
#closed? ⇒ Boolean
909
910
911
|
# File 'lib/memcache.rb', line 909
def closed?
@sock.closed?
end
|
#gets(*args) ⇒ Object
889
890
891
892
893
|
# File 'lib/memcache.rb', line 889
def gets(*args)
MemCacheTimer.timeout(@len) do
@sock.gets(*args)
end
end
|
#read(*args) ⇒ Object
895
896
897
898
899
|
# File 'lib/memcache.rb', line 895
def read(*args)
MemCacheTimer.timeout(@len) do
@sock.read(*args)
end
end
|
#write(*args) ⇒ Object
883
884
885
886
887
|
# File 'lib/memcache.rb', line 883
def write(*args)
MemCacheTimer.timeout(@len) do
@sock.write(*args)
end
end
|