Module: Dalli::Socket::InstanceMethods
Instance Method Summary collapse
Instance Method Details
#read_available ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/dalli/socket.rb', line 28 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
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/dalli/socket.rb', line 10 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
45 46 47 |
# File 'lib/dalli/socket.rb', line 45 def .reject { |k, v| [:username, :password].include? k } end |