Sha256: 4f964c46351e249d6b52855486b197be131e22c6966feb4fa1cc710e82207da2

Contents?: true

Size: 1.63 KB

Versions: 6

Compression:

Stored size: 1.63 KB

Contents

## API docs: http://docs.aws.amazon.com/sdkforruby/api/Aws/ElastiCache/Client.html

module AwsClient
  class ElastiCacheWrapper < AwsClient::Wrapper
   
     def memcached_endpoints_by_identifier(identifier)
      cluster = memcached_cluster_by_identifier(identifier)
      return [] unless cluster
      cluster.cache_nodes.collect{|cache_node| cache_node.endpoint }
    end

    def redis_endpoints_by_identifier(identifier)
      cluster = redis_cluster_by_identifier(identifier)
      return [] unless cluster
      cluster.cache_nodes.collect{|cache_node| cache_node.endpoint }
    end  
 
    def redis_cluster_by_identifier(identifier)
      redis_clusters.select{|cluster| cluster.cache_cluster_id == identifier }.first
    end

    def memcached_cluster_by_identifier(identifier)
      memcache_clusters.select{|cluster| cluster.cache_cluster_id == identifier }.first
    end
  
    def redis_clusters
      clusters_by_engine_type("redis")
    end 

    def memcache_clusters
      clusters_by_engine_type("memcached")
    end
  
    def clusters_by_engine_type(engine_type)
      cache_clusters.select{|cache_cluster| cache_cluster.engine == engine_type }
    end

    def cache_clusters
      all_cache_messages = get_all_instances
      return all_cache_messages.collect{|cache_message| cache_message.cache_clusters }.flatten
    end

    def get_all_instances
      all_instances = []
      pages = client.describe_cache_clusters(:show_cache_node_info => true)
      all_instances << pages.data
      while pages.next_page?
        pages = pages.next_page
        @all_instances << pages.data
      end
      return all_instances
    end


  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
aws_client-0.1.3 lib/elasticache_wrapper.rb
aws_client-0.1.2 lib/elasticache_wrapper.rb
aws_client-0.1.1 lib/elasticache_wrapper.rb
aws_client-0.0.93 lib/elasticache_wrapper.rb
aws_client-0.0.92 lib/elasticache_wrapper.rb
aws_client-0.0.91 lib/elasticache_wrapper.rb