Class: Dalli::ElastiCache

Inherits:
Object
  • Object
show all
Defined in:
lib/dalli/elasticache.rb,
lib/dalli/elasticache/version.rb

Constant Summary collapse

VERSION =
"0.1.2"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_endpoint, options = {}) ⇒ ElastiCache

Returns a new instance of ElastiCache.



12
13
14
15
# File 'lib/dalli/elasticache.rb', line 12

def initialize(config_endpoint, options={})
  @endpoint = Dalli::Elasticache::AutoDiscovery::Endpoint.new(config_endpoint)
  @options = options
end

Instance Attribute Details

#endpointObject (readonly)

Returns the value of attribute endpoint.



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

def endpoint
  @endpoint
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#clientObject

Dalli::Client configured to connect to the cluster’s nodes



18
19
20
# File 'lib/dalli/elasticache.rb', line 18

def client
  Dalli::Client.new(servers, options)
end

#engine_versionObject

The cache engine version of the cluster



30
31
32
# File 'lib/dalli/elasticache.rb', line 30

def engine_version
  endpoint.engine_version
end

#refreshObject

Clear all cached data from the cluster endpoint



40
41
42
43
44
45
# File 'lib/dalli/elasticache.rb', line 40

def refresh
  config_endpoint = "#{endpoint.host}:#{endpoint.port}"
  @endpoint = Dalli::Elasticache::AutoDiscovery::Endpoint.new(config_endpoint)
  
  self
end

#serversObject

List of cluster server nodes with ip addresses and ports



35
36
37
# File 'lib/dalli/elasticache.rb', line 35

def servers
  endpoint.config.nodes.map{ |h| "#{h[:ip]}:#{h[:port]}" }
end

#versionObject

The number of times the cluster configuration has been changed

Returns an integer



25
26
27
# File 'lib/dalli/elasticache.rb', line 25

def version
  endpoint.config.version
end