Skip to content

Instantly share code, notes, and snippets.

@wesgarrison
Created April 28, 2015 18:31
Show Gist options
  • Save wesgarrison/5bed9480ed1eb4424e0b to your computer and use it in GitHub Desktop.
Save wesgarrison/5bed9480ed1eb4424e0b to your computer and use it in GitHub Desktop.
Rails.cache.fetch ('nil thing') { nil }
Cache read: nil thing
Cache generate: nil thing
Cache write: nil thing
Rails.cache.fetch ('nil thing') { nil }

Note: it can't find it, so it regenerates it.

Cache read: nil thing
Cache generate: nil thing
Cache write: nil thing
Rails.cache.fetch ('one thing') { 1 }
Cache read: one thing
Cache generate: one thing
Cache write: one thing
Rails.cache.fetch ('one thing') { 1 }

Note: it can find it, so there's a cache fetch_hit.

Cache read: one thing
Cache fetch_hit: one thing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment