使用Dalli列出远程服务器中的所有缓存项

时间:2015-03-16 18:04:22

标签: ruby caching heroku memcached dalli

我最近在Memcached中学到了更多知识,以及Dalli如何与不同的缓存策略一起发挥作用。我正在尝试使用我们的一个生产级项目远程连接到heroku上的memcachier。通过一些教程,我发现了如何通过Dalli远程连接到远程memcachier。

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

我确认它在我运行ruby sandbox.rb并且出现输出时有效:

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"}}

我一直试图找出如何深入挖掘缓存的键和值。更具体一点:我想至少列出使用Dalli当前在memcached中的所有键和值。我似乎找不到合适的解决方案。我找到的最佳匹配是gist,它可以帮助您在本地获取它。

有什么想法?

0 个答案:

没有答案