Heroku / Memcache / Rack :: Cache Stats [英] Heroku/Memcache/Rack::Cache Stats

查看:107
本文介绍了Heroku / Memcache / Rack :: Cache Stats的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图围绕Rack :: Cache,Rails 3.2,Memcache和Heroku围绕我的大脑。我想我已经把它们合在一起,如下所述: http://myownpirateradio.com/2012/01/01/getting-heroku-cedar-and-rails-3-1-asset-pipeline-to / play-nice-together /

所有这些都说明了,我不确定Memcached是否真的在做它应该做的事情。有没有办法在Memcached上获取统计信息,或者查看是否有Memcached缓存请求?我把当前时间放在一个页面上,可以看到它正在缓存(标题看起来不错),但是我怎么知道它全部与Memcached协同工作,而不是文件存储?



谢谢。

解决方案

您可以通过以下方式获取有关memcached的统计信息:

<$ p $
运行控制台连接到终端... up,run.1
加载生产环境(Rails 3.1.3)
irb(main) :001:0> Rails.cache.stats
Dalli / SASL认证为app590983%40heroku.com
Dalli / SASL:已认证
=> {mc5.ec2.northscale.net:11211\"=>{\"evictions\"=>\"0,curr_items=>627,
total_items=>1257, bytes=>2294318,reclaimed=>0,
engine_maxbytes=>5242880,bucket_conns=>2,pid 319,
正常运行时间=>6710022,时间=>1330731177,版本=>1.4.4_207_g19c6b9e,
libevent=> 1.4.11-stable,pointer_size=>64,
rusage_user=>34354.590000,rusage_system=>31381.520000,
daemon_connections= >10,curr_connections=>1211,
total_connections=>14127919,connection_structures=>1764,
cmd_get=> 9476,cmd_set=>1257,cmd_flush=>0,auth_cmds=>24,
auth_errors=>0,get_hits =8093,get_misses=>1383,
delete_misses=>0,delete_hits=>0,incr_misses=>0 ,
incr_hits=>0,decr_misses=>0,decr_hits=>0,cas_misses=>0 $ bcas_hits=>0,cas_badval=>0,bytes_read=>21983909,
bytes_written=>85267718,limit_maxbytes= >67108864,
rejected_conns=>0,threads=>4,conn_yields=>0}}

您还可以运行 Rails.cache.class 来查看Rails使用的后端。


I am trying to wrap my brain around Rack::Cache, Rails 3.2, Memcache, and Heroku. I think I've got it all working together, as outlined here: http://myownpirateradio.com/2012/01/01/getting-heroku-cedar-and-rails-3-1-asset-pipeline-to-play-nicely-together/

All that said, I am unsure if Memcached is actually doing what it should. Is there any way to get stats on Memcached or to see if a request was cached by Memcached? I put the current time on a page, and can see that it is getting cached (headers look good too), but how do I know it is all working with Memcached, as opposed to the file store?

Thanks.

解决方案

You can get stats on memcached by doing:

$ heroku run console
Running console attached to terminal... up, run.1
Loading production environment (Rails 3.1.3)
irb(main):001:0> Rails.cache.stats
Dalli/SASL authenticating as app590983%40heroku.com
Dalli/SASL: Authenticated
=> {"mc5.ec2.northscale.net:11211"=>{"evictions"=>"0", "curr_items"=>"627",
    "total_items"=>"1257", "bytes"=>"2294318", "reclaimed"=>"0", 
    "engine_maxbytes"=>"5242880", "bucket_conns"=>"2", "pid"=>"319", 
    "uptime"=>"6710022", "time"=>"1330731177", "version"=>"1.4.4_207_g19c6b9e", 
    "libevent"=>"1.4.11-stable", "pointer_size"=>"64", 
    "rusage_user"=>"34354.590000", "rusage_system"=>"31381.520000", 
    "daemon_connections"=>"10", "curr_connections"=>"1211", 
    "total_connections"=>"14127919", "connection_structures"=>"1764", 
    "cmd_get"=>"9476", "cmd_set"=>"1257", "cmd_flush"=>"0", "auth_cmds"=>"24", 
    "auth_errors"=>"0", "get_hits"=>"8093", "get_misses"=>"1383", 
    "delete_misses"=>"0", "delete_hits"=>"0", "incr_misses"=>"0", 
    "incr_hits"=>"0", "decr_misses"=>"0", "decr_hits"=>"0", "cas_misses"=>"0", 
    "cas_hits"=>"0", "cas_badval"=>"0", "bytes_read"=>"21983909", 
    "bytes_written"=>"85267718", "limit_maxbytes"=>"67108864", 
    "rejected_conns"=>"0", "threads"=>"4", "conn_yields"=>"0"}}

PS: I think you might need to be using the Dalli gem for this to work, but that is the recommended client anyway.

You can also run Rails.cache.class to see which backend is Rails using.

这篇关于Heroku / Memcache / Rack :: Cache Stats的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆