5

I have been recently picking up more learnings with Memcached and how Dalli plays along with the different caching strategies. I am trying to connect remotely to our memcachier on heroku with one of our production level projects. Through some tutorial, I found out how to connect remotely to remote memcachier through Dalli.

sandbox.rb:

require 'dalli'

memcachier_server = 'host_name:port'
memcachier_user = 'abc123'
memcachier_password = '1x8w3asdf82jdf'

cache = Dalli::Client.new(memcachier_server,
                                    {
                                        :username => memcachier_user,
                                        :password => memcachier_password,
                                        :failover => true,
                                        :socket_timeout => 1.5,
                                        :socket_failure_delay => 0.2
                                    })

p cache.stat

I confirmed it works when i run ruby sandbox.rb and there comes the output:

I, [2015-03-17T01:45:20.703729 #42640]  INFO -- : Dalli/SASL authenticating as abc123
I, [2015-03-17T01:45:21.305454 #42640]  INFO -- : Dalli/SASL: abc123
{"xyz.memcacheir.com:11211"=>{"curr_items"=>"24446", "bytes"=>"110738688", "evictions"=>"2586065", "expired"=>"0", "cas_hits"=>"0", "cas_misses"=>"0", "cas_badval"=>"0", "limit_maxbytes"=>"120586239", "total_items"=>"3782835", "bytes_read"=>"1559184266", "bytes_written"=>"33808073647", "curr_connections"=>"5", "total_connections"=>"1098", "auth_cmds"=>"1098", "auth_errors"=>"0", "cmd_get"=>"19371543", "cmd_set"=>"3782835", "cmd_delete"=>"15829", "cmd_touch"=>"0", "cmd_flush"=>"0", "get_hits"=>"16476147", "get_misses"=>"2895396", "delete_hits"=>"4131", "delete_misses"=>"11698", "incr_hits"=>"0", "incr_misses"=>"0", "decr_hits"=>"0", "decr_misses"=>"0", "touch_hits"=>"0", "touch_misses"=>"0", "time"=>"1426527920"}}

I have been trying to find out how I can dig in more into the cached keys and values. To be more specific: I want to at least list out all Keys and values currently in memcached using Dalli. I can't seem to find an appropriate solution. The best match i found is this gist which helps you with getting it locally.

Any thoughts?

Chris Yeung
  • 2,613
  • 6
  • 34
  • 57

0 Answers0