2

I am using Rails.cache.read/write/fetch methods. When I perform these operations I see the following messages (see below) in my log. I wanted to know what they mean, I understand read/write message, but how about Fetch Hit and Generate.

Use case(Cache is empty) - So when I use Rails.cache.fetch("city/#{key}") { return city_object } I see 3 log messages - Read, Generate & Write. However if I use read(check if key exists)/(else)write, I only see read & write messages, so was wondering whats more efficient.

CACHE Read city/key1

CACHE Write city/key1

CACHE Generate city/key1

CACHE Fetch Hit city/key1

Also a fetch with a block generates both "Read..." & "Fetch Hit..." messages, while just a read generates only "Read..." message. In both cases cache had the key/value pair.

This is a Rails 3.2.8 app and I am using dalli gem as the memcached client.

kapso
  • 11,703
  • 16
  • 58
  • 76
  • Did you work this out mate? I'm seeing Cache read and Cache fetch_hit too, and it doesn't seem to be caching. – A4J Sep 20 '12 at 12:17

0 Answers0