Memcached stats 命令
stats 查看全局运行指标(连接、命中率、内存)。
Key Pointsstats 的 get_hits / get_misses 之比就是缓存命中率,最该盯的指标。
关键指标
Shell
statsOutput
STAT pid 1234
STAT uptime 3600
STAT curr_connections 5
STAT cmd_get 1000
STAT cmd_set 200
STAT get_hits 850
STAT get_misses 150
STAT bytes 4096
STAT limit_maxbytes 67108864命中率
Hit rate = get_hits / (get_hits + get_misses) = 850/1000 = 85%. A low rate means the cache isn't shielding the DB — TTL too short, or keys vary every request.
limit_maxbytes is the -m cap; bytes is current usage. As usage nears the cap, LRU eviction kicks in and hit rate fluctuates. Watch both together.关键指标
Shell
statsOutput
STAT pid 1234
STAT uptime 3600
STAT curr_connections 5
STAT cmd_get 1000
STAT cmd_set 200
STAT get_hits 850
STAT get_misses 150
STAT bytes 4096
STAT limit_maxbytes 67108864命中率
命中率 = get_hits / (get_hits + get_misses) = 850 / 1000 = 85%。命中率过低说明缓存没挡住数据库——要么 TTL 太短、要么 key 设计不合理(如每次都变)。
limit_maxbytes 是 -m 设的内存上限;bytes 是当前用量。当用量逼近上限,LRU 开始淘汰,命中率会波动。监控里把命中率和内存占用一起看。