【问题标题】:Heroku/Memcache/Rack::Cache StatsHeroku/Memcache/Rack::缓存统计
【发布时间】:2012-03-21 11:01:15
【问题描述】:

我正试图围绕 Rack::Cache、Rails 3.2、Memcache 和 Heroku。我想我已经把这一切一起工作了,如下所述:http://myownpirateradio.com/2012/01/01/getting-heroku-cedar-and-rails-3-1-asset-pipeline-to-play-nicely-together/

说了这么多,我不确定 Memcached 是否真的在做它应该做的事情。有什么方法可以获取 Memcached 的统计信息或查看 Memcached 是否缓存了请求?我将当前时间放在页面上,并且可以看到它正在被缓存(标题看起来也不错),但我怎么知道它全部使用 Memcached,而不是文件存储?

谢谢。

【问题讨论】:

    标签: ruby-on-rails ruby heroku memcached


    【解决方案1】:

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

    $ 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:我认为您可能需要使用 Dalli gem 才能使其工作,但无论如何这是推荐的客户端。

    您也可以运行 Rails.cache.class 来查看 Rails 使用的是哪个后端。

    【讨论】:

    • 谢谢!知道了解 Rails.cache.stats 输出的任何资源吗?
    • 并非如此,大多数键似乎都具有自我描述性。如果您有什么具体想知道的,可以发帖提问。
    • 我有一个类似的问题 (stackoverflow.com/questions/10115187/…) - 这并没有让我得到答案......任何帮助将不胜感激! @Jakub-hampl
    • @MattFordham 这对我帮助很大pal-blog.de/entwicklung/perl/…
    猜你喜欢
    • 2010-12-11
    • 1970-01-01
    • 1970-01-01
    • 2011-11-04
    • 1970-01-01
    • 1970-01-01
    • 2012-09-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多