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

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

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) ⇒ Endpoint

Returns a new instance of Endpoint.



18
19
20
21
22
23
# File 'lib/dalli/elasticache/auto_discovery/endpoint.rb', line 18

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

Instance Attribute Details

#hostObject (readonly)

Endpoint configuration



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

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



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

def port
  @port
end

Instance Method Details

#configObject

A cached ElastiCache::ConfigResponse



31
32
33
# File 'lib/dalli/elasticache/auto_discovery/endpoint.rb', line 31

def config
  @config ||= get_config_from_remote
end

#engine_versionObject

The memcached engine version



36
37
38
# File 'lib/dalli/elasticache/auto_discovery/endpoint.rb', line 36

def engine_version
  stats.version
end

#statsObject

A cached ElastiCache::StatsResponse



26
27
28
# File 'lib/dalli/elasticache/auto_discovery/endpoint.rb', line 26

def stats
  @stats ||= get_stats_from_remote
end