我刚刚使用 memcachier 和 dalli 在 Heroku 上托管的网站上设置了 memcached。我已将主页包装在片段缓存块中。在我的日志中,我可以看到片段正在被缓存并正确读取,并且我已经发现负载测试的结果有了很大的改善。但我想知道为什么我仍然看到所有这些模型查找发生。我的理解是,我应该可以完全避免数据库之行。我的日志中的“国家负载”语句是否仅表示从缓存中加载模型?或者我可以通过改变缓存的方式来避免它们吗?
谢谢你的帮助!
2013-04-03T22:48:03+00:00 app[web.1]: Read fragment views/home (15.4ms)
2013-04-03T22:48:03+00:00 app[web.1]: Rendered shared/_home.html (18.8ms)
2013-04-03T22:48:03+00:00 app[web.1]: Rendered cities/index.html within layouts/application (51.6ms)
2013-04-03T22:48:03+00:00 app[web.1]: Country Load (9.7ms) SELECT "countries".* FROM "countries" WHERE "countries"."name" = 'united states' LIMIT 1
2013-04-03T22:48:03+00:00 app[web.1]: Country Load (5.0ms) SELECT "countries".* FROM "countries" WHERE "countries"."name" = 'france' LIMIT 1
2013-04-03T22:48:03+00:00 app[web.1]: Country Load (4.1ms) SELECT "countries".* FROM "countries" WHERE "countries"."name" = 'spain' LIMIT 1
2013-04-03T22:48:03+00:00 app[web.1]: Country Load (4.3ms) SELECT "countries".* FROM "countries" WHERE "countries"."name" = 'united kingdom' LIMIT 1
2013-04-03T22:48:03+00:00 app[web.1]: Country Load (3.4ms) SELECT "countries".* FROM "countries" WHERE "countries"."name" = 'brazil' LIMIT 1
2013-04-03T22:48:03+00:00 app[web.1]: Country Load (3.5ms) SELECT "countries".* FROM "countries" WHERE "countries"."name" = 'china' LIMIT 1
2013-04-03T22:48:03+00:00 app[web.1]: Country Load (3.0ms) SELECT "countries".* FROM "countries" WHERE "countries"."name" = 'germany' LIMIT 1
2013-04-03T22:48:03+00:00 app[web.1]: Country Load (2.8ms) SELECT "countries".* FROM "countries" WHERE "countries"."name" = 'argentina' LIMIT 1
2013-04-03T22:48:03+00:00 app[web.1]: Country Load (12.9ms) SELECT "countries".* FROM "countries" WHERE "countries"."name" = 'japan' LIMIT 1
2013-04-03T22:48:03+00:00 app[web.1]: Country Load (2.9ms) SELECT "countries".* FROM "countries" WHERE "countries"."name" = 'italy' LIMIT 1
2013-04-03T22:48:03+00:00 app[web.1]: Country Load (3.6ms) SELECT "countries".* FROM "countries" WHERE "countries"."name" = 'canada' LIMIT 1
2013-04-03T22:48:03+00:00 app[web.1]: Country Load (3.3ms) SELECT "countries".* FROM "countries" WHERE "countries"."name" = 'thailand' LIMIT 1
2013-04-03T22:48:03+00:00 app[web.1]: Country Load (3.2ms) SELECT "countries".* FROM "countries" WHERE "countries"."name" = 'colombia' LIMIT 1
2013-04-03T22:48:03+00:00 app[web.1]: Country Load (3.6ms) SELECT "countries".* FROM "countries" WHERE "countries"."name" = 'south korea' LIMIT 1
2013-04-03T22:48:03+00:00 app[web.1]: Country Load (10.7ms) SELECT "countries".* FROM "countries" WHERE "countries"."name" = 'sweden' LIMIT 1
2013-04-03T22:48:03+00:00 app[web.1]: Country Load (3.0ms) SELECT "countries".* FROM "countries" WHERE "countries"."name" = 'singapore' LIMIT 1
2013-04-03T22:48:03+00:00 app[web.1]: Completed 200 OK in 743ms (Views: 359.6ms | ActiveRecord: 382.2ms)