No commit activity in last 3 years
No release in over 3 years
This gem provides an interface for fetching cluster information from an AWS ElastiCache AutoDiscovery server and configuring a Dalli client to connect to all nodes in the cache cluster.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

>= 1.0.0
 Project Readme

Dalli ElastiCache Gem Version Build Status Code Climate

Use AWS ElastiCache AutoDiscovery to automatically configure your Dalli memcached client with all the nodes in your cluster.

Installation

Install the rubygem:

# in your Gemfile
gem 'dalli-elasticache'

Setup for Rails 3.x and Newer

Configure your environment-specific application settings:

# in config/environments/production.rb
endpoint    = "my-cluster-name.abc123.cfg.use1.cache.amazonaws.com:11211"
elasticache = Dalli::ElastiCache.new(endpoint)

config.cache_store = :dalli_store, elasticache.servers, {:expires_in => 1.day, :compress => true}

Note that the ElastiCache server list will be refreshed each time an app server process starts.

Client Usage

Create an ElastiCache instance:

config_endpoint = "aaron-scratch.vfdnac.cfg.use1.cache.amazonaws.com:11211"

# Options for configuring the Dalli::Client
dalli_options = {
  :expires_in => 24 * 60 * 60,
  :namespace => "my_app",
  :compress => true
}

elasticache = Dalli::ElastiCache.new(config_endpoint, dalli_options)

Fetch information about the Memcached nodes:

# Dalli::Client with configuration from the AutoDiscovery endpoint
elasticache.client
# => #<Dalli::Client ... @servers=["aaron-scratch.vfdnac.0001.use1.cache.amazonaws.com:11211", ...]>

# Node addresses
elasticache.servers
# => ["aaron-scratch.vfdnac.0001.use1.cache.amazonaws.com:11211", "aaron-scratch.vfdnac.0002.use1.cache.amazonaws.com:11211"]

# Number of times the cluster configuration has changed
elasticache.version
# => 12

# Memcached version of the cluster
elasticache.engine_version
# => "1.4.14"

# Refresh data from the endpoint
elasticache.refresh

# Refresh and get client with new configuration
elasticache.refresh.client

License

Copyright 2013 Aaron Suggs

Released under an MIT License