Class: ElasticSearch::Transport::Memcached

Inherits:
Base
  • Object
show all
Defined in:
lib/elasticsearch/transport/memcached.rb

Defined Under Namespace

Classes: Response

Constant Summary collapse

DEFAULTS =
{
  :timeout => 5
}.freeze

Instance Attribute Summary

Attributes inherited from Base

#options, #server

Instance Method Summary collapse

Methods inherited from Base

#encoder

Methods included from ClusterAdminProtocol

#cluster_health, #cluster_state, #nodes_info, #nodes_stats, #restart_nodes, #shutdown_nodes

Methods included from IndexAdminProtocol

#alias_index, #create_index, #create_river, #delete_index, #delete_mapping, #delete_river, #flush, #get_aliases, #get_river, #get_settings, #index_mapping, #index_status, #optimize, #refresh, #river_status, #snapshot, #update_mapping, #update_settings

Methods included from IndexProtocol

#bulk, #count, #delete, #delete_by_query, #get, #index, #multi_get, #scroll, #search

Constructor Details

#initialize(server, options = {}) ⇒ Memcached

Returns a new instance of Memcached.



16
17
18
19
# File 'lib/elasticsearch/transport/memcached.rb', line 16

def initialize(server, options={})
  super
  @options = DEFAULTS.merge(@options)
end

Instance Method Details

#all_nodesObject



29
30
31
32
33
34
35
36
37
# File 'lib/elasticsearch/transport/memcached.rb', line 29

def all_nodes
  memcached_addresses = nodes_info([])["nodes"].collect { |id, node| node["memcached_address"] }
  memcached_addresses.collect! do |a|
    if a =~ /inet\[.*\/([\d.:]+)\]/
      $1
    end
  end.compact!
  memcached_addresses
end

#closeObject



25
26
27
# File 'lib/elasticsearch/transport/memcached.rb', line 25

def close
  @memcached.quit
end

#connect!Object



21
22
23
# File 'lib/elasticsearch/transport/memcached.rb', line 21

def connect!
  @memcached = ::Memcached.new(@server, :timeout => @options[:timeout]) #TODO allow passing other options?
end