提交 068ab23a 编写于 作者: R Robin Dupret

Tiny documentation fixes [ci skip]

上级 3f767aa9
...@@ -70,13 +70,13 @@ code: ...@@ -70,13 +70,13 @@ code:
When your application receives its first request to this page, Rails will write When your application receives its first request to this page, Rails will write
a new cache entry with a unique key. A key looks something like this: a new cache entry with a unique key. A key looks something like this:
```html ```
views/products/1-201505056193031061005000/bea67108094918eeba42cd4a6e786901 views/products/1-201505056193031061005000/bea67108094918eeba42cd4a6e786901
``` ```
The number in the middle is the `product_id` followed by the timestamp value in The number in the middle is the `product_id` followed by the timestamp value in
the `updated_at` value of the product record. Rails uses the timestamp value to the `updated_at` attribute of the product record. Rails uses the timestamp value
make sure it is not serving stale data. If the value of `updated_at` has to make sure it is not serving stale data. If the value of `updated_at` has
changed, a new key will be generated. Then Rails will write a new cache to that changed, a new key will be generated. Then Rails will write a new cache to that
key, and the old cache written to the old key will never be used again. This is key, and the old cache written to the old key will never be used again. This is
called key-based expiration. called key-based expiration.
...@@ -90,7 +90,7 @@ will change, expiring the existing file. ...@@ -90,7 +90,7 @@ will change, expiring the existing file.
TIP: Cache stores like Memcached will automatically delete old cache files. TIP: Cache stores like Memcached will automatically delete old cache files.
If you want to cache a fragment under certain conditions, you can use If you want to cache a fragment under certain conditions, you can use
`cache_if` or `cache_unless` `cache_if` or `cache_unless`:
```erb ```erb
<% cache_if admin?, product do %> <% cache_if admin?, product do %>
...@@ -144,8 +144,8 @@ end ...@@ -144,8 +144,8 @@ end
``` ```
With `touch` set to true, any action which changes `updated_at` for a game With `touch` set to true, any action which changes `updated_at` for a game
column will also change it in the associated product column, thereby expiring record will also change it for the associated product, thereby expiring the
the cache. cache.
### Low-Level Caching ### Low-Level Caching
...@@ -410,6 +410,8 @@ class ProductsController < ApplicationController ...@@ -410,6 +410,8 @@ class ProductsController < ApplicationController
end end
``` ```
### References References
----------
* [DHH's article on key-based expiration](https://signalvnoise.com/posts/3113-how-key-based-cache-expiration-works) * [DHH's article on key-based expiration](https://signalvnoise.com/posts/3113-how-key-based-cache-expiration-works)
* [Ryan Bates' Railscast on cache digests](http://railscasts.com/episodes/387-cache-digests) * [Ryan Bates' Railscast on cache digests](http://railscasts.com/episodes/387-cache-digests)
...@@ -9,7 +9,7 @@ After reading this guide, you will know: ...@@ -9,7 +9,7 @@ After reading this guide, you will know:
* How to set up your machine for Rails development * How to set up your machine for Rails development
* How to run specific groups of unit tests from the Rails test suite * How to run specific groups of unit tests from the Rails test suite
* How the ActiveRecord portion of the Rails test suite operates * How the Active Record portion of the Rails test suite operates
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
...@@ -60,7 +60,7 @@ In Ubuntu you're done with just: ...@@ -60,7 +60,7 @@ In Ubuntu you're done with just:
$ sudo apt-get install sqlite3 libsqlite3-dev $ sudo apt-get install sqlite3 libsqlite3-dev
``` ```
And if you are on Fedora or CentOS, you're done with If you are on Fedora or CentOS, you're done with
```bash ```bash
$ sudo yum install sqlite3 sqlite3-devel $ sudo yum install sqlite3 sqlite3-devel
...@@ -213,7 +213,7 @@ FreeBSD users will have to run the following: ...@@ -213,7 +213,7 @@ FreeBSD users will have to run the following:
```bash ```bash
# pkg install mysql56-client mysql56-server # pkg install mysql56-client mysql56-server
# pkg install postgresql93-client postgresql93-server # pkg install postgresql94-client postgresql94-server
``` ```
Or install them through ports (they are located under the `databases` folder). Or install them through ports (they are located under the `databases` folder).
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册