Class: Dalli::Socket::UNIX

Inherits:
UNIXSocket
  • Object
show all
Includes:
InstanceMethods
Defined in:
lib/dalli/socket.rb,
lib/dalli/socket.rb

Overview

UNIX represents a UNIX domain socket, which is an interprocess communication mechanism between processes on the same host. Used when the Memcached server is running on the same machine as the Dalli client.

Constant Summary

Constants included from InstanceMethods

InstanceMethods::FILTERED_OUT_OPTIONS, InstanceMethods::WAIT_RCS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from InstanceMethods

#append_to_buffer?, #logged_options, #nonblock_timed_out?, #read_available, #readfull

Constructor Details

#initialize(*_args) ⇒ UNIX

Returns a new instance of UNIX.

Raises:



202
203
204
# File 'lib/dalli/socket.rb', line 202

def initialize(*_args)
  raise Dalli::DalliError, 'Unix sockets are not supported on Windows platform.'
end

Instance Attribute Details

#optionsObject

options - supports enhanced logging in the case of a timeout server - used to support IO.select in the pipelined getter



218
219
220
# File 'lib/dalli/socket.rb', line 218

def options
  @options
end

Class Method Details

.init_socket_options(sock, options) ⇒ Object



229
230
231
232
233
# File 'lib/dalli/socket.rb', line 229

def self.init_socket_options(sock, options)
  # https://man7.org/linux/man-pages/man7/unix.7.html
  sock.setsockopt(::Socket::SOL_SOCKET, ::Socket::SO_SNDBUF, options[:sndbuf]) if options[:sndbuf]
  sock.timeout = options[:socket_timeout] if options[:socket_timeout] && sock.respond_to?(:timeout=)
end

.open(path, options = {}) ⇒ Object



220
221
222
223
224
225
226
227
# File 'lib/dalli/socket.rb', line 220

def self.open(path, options = {})
  Timeout.timeout(options[:socket_timeout]) do
    sock = new(path)
    sock.options = { path: path }.merge(options)
    init_socket_options(sock, options)
    sock
  end
end