I've just got memcached setup on my website hosted on Heroku using memcachier and dalli. I have wrapped my homepage in a fragment cache block. In my logs, I can see that the fragment is being cached and read correctly, and I've already found that the results from load testing have greatly improved. But I'm wondering why I still see all these model lookups occuring. My understanding is that I should be able to completely avoid the trip to the database. Do the "Country Load" statements in my logs just represent loading the model from the cache? Or can I avoid them by changing how I'm doing caching?
Thanks for any help!
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)
Fragment caching in a view won't catch the layout - do you have a header or footer element that displays countries? You can wrap these in another fragment cache, as well.