Class: Dalli::Elasticache::AutoDiscovery::Endpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/dalli/elasticache/auto_discovery/endpoint.rb

Defined Under Namespace

Classes: Timeout

Constant Summary collapse

ENDPOINT_REGEX =

Matches Strings like “my-host.cache.aws.com:11211”

/([-.a-zA-Z0-9]+):(\d+)/
STATS_COMMAND =
"stats\r\n"
CONFIG_COMMAND =
"config get cluster\r\n"
OLD_CONFIG_COMMAND =

Legacy command for version < 1.4.14

"get AmazonElastiCache:cluster\r\n"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endpoint, timeout) ⇒ Endpoint

Returns a new instance of Endpoint.



20
21
22
23
24
25
26
# File 'lib/dalli/elasticache/auto_discovery/endpoint.rb', line 20

def initialize(endpoint, timeout)
  ENDPOINT_REGEX.match(endpoint) do |m|
    @host = m[1]
    @port = m[2].to_i
  end
  @timeout = timeout
end

Instance Attribute Details

#hostObject (readonly)

Endpoint configuration



8
9
10
# File 'lib/dalli/elasticache/auto_discovery/endpoint.rb', line 8

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



9
10
11
# File 'lib/dalli/elasticache/auto_discovery/endpoint.rb', line 9

def port
  @port
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



10
11
12
# File 'lib/dalli/elasticache/auto_discovery/endpoint.rb', line 10

def timeout
  @timeout
end

Instance Method Details

#configObject

A cached ElastiCache::ConfigResponse



34
35
36
# File 'lib/dalli/elasticache/auto_discovery/endpoint.rb', line 34

def config
  @config ||= get_config_from_remote
end

#engine_versionObject

The memcached engine version



39
40
41
# File 'lib/dalli/elasticache/auto_discovery/endpoint.rb', line 39

def engine_version
  stats.version
end

#statsObject

A cached ElastiCache::StatsResponse



29
30
31
# File 'lib/dalli/elasticache/auto_discovery/endpoint.rb', line 29

def stats
  @stats ||= get_stats_from_remote
end