Module: Dalli::Socket::InstanceMethods
Instance Method Summary collapse
Instance Method Details
#read_available ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/dalli/socket.rb', line 27 def read_available value = +"" loop do result = read_nonblock(8196, exception: false) if result == :wait_readable break elsif result == :wait_writable break elsif result value << result else raise Errno::ECONNRESET, "Connection reset: #{.inspect}" end end value end |
#readfull(count) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/dalli/socket.rb', line 9 def readfull(count) value = +"" loop do result = read_nonblock(count - value.bytesize, exception: false) if result == :wait_readable raise Timeout::Error, "IO timeout: #{.inspect}" unless IO.select([self], nil, nil, [:socket_timeout]) elsif result == :wait_writable raise Timeout::Error, "IO timeout: #{.inspect}" unless IO.select(nil, [self], nil, [:socket_timeout]) elsif result value << result else raise Errno::ECONNRESET, "Connection reset: #{.inspect}" end break if value.bytesize == count end value end |
#safe_options ⇒ Object
44 45 46 |
# File 'lib/dalli/socket.rb', line 44 def .reject { |k, v| [:username, :password].include? k } end |