diff options
author | Santosh Wadghule <santosh.wadghule@gmail.com> | 2016-07-21 14:55:44 +0530 |
---|---|---|
committer | Santosh Wadghule <santosh.wadghule@gmail.com> | 2016-07-24 09:37:44 +0530 |
commit | d4f1b8090a0be336b0b948e09ebca9144bb7c9d8 (patch) | |
tree | b5a369f820b52b952282065029ed4ff934817010 | |
parent | cf5bc0dd5359e61dcb93e719279c7198e68a0eb8 (diff) | |
download | rails-d4f1b8090a0be336b0b948e09ebca9144bb7c9d8.tar.gz rails-d4f1b8090a0be336b0b948e09ebca9144bb7c9d8.tar.bz2 rails-d4f1b8090a0be336b0b948e09ebca9144bb7c9d8.zip |
Proper description for `Rails.cache.fetch` [ci skip]
-rw-r--r-- | guides/source/caching_with_rails.md | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/guides/source/caching_with_rails.md b/guides/source/caching_with_rails.md index 6c734c1d78..285e4ece48 100644 --- a/guides/source/caching_with_rails.md +++ b/guides/source/caching_with_rails.md @@ -270,7 +270,7 @@ simply be explicit in a comment, like: Sometimes you need to cache a particular value or query result instead of caching view fragments. Rails' caching mechanism works great for storing __any__ kind of information. -The most efficient way to implement low-level caching is using the `Rails.cache.fetch` method. This method does both reading and writing to the cache. When passed only a single argument, the key is fetched and value from the cache is returned. If a block is passed, the result of the block will be cached to the given key and the result is returned. +The most efficient way to implement low-level caching is using the `Rails.cache.fetch` method. This method does both reading and writing to the cache. When passed only a single argument, the key is fetched and value from the cache is returned. If a block is passed, that block will be executed in the event of a cache miss. The return value of the block will be written to the cache under the given cache key, and that return value will be returned. In case of cache hit, the cached value will be returned without executing the block. Consider the following example. An application has a `Product` model with an instance method that looks up the product’s price on a competing website. The data returned by this method would be perfect for low-level caching: |