Commit 5c933fae by Carsten Brandt

added docs about query caching. fixes #1917

parent 2c86d7a1
......@@ -6,7 +6,7 @@ static data in cache and serving it from cache when requested, the application s
Base Concepts
--------------------------
-------------
Using cache in Yii involves configuring and accessing a cache application component. The following
application configuration specifies a cache component that uses [memcached](http://memcached.org/) with
......@@ -182,7 +182,15 @@ Below is a summary of the available cache dependencies:
### Query Caching
TBD: http://www.yiiframework.com/doc/guide/1.1/en/caching.data#query-caching
For caching the result of database queries you can wrap them in calls to [[yii\db\Connection::beginCache()]]
and [[yii\db\Connection::endCache()]]:
```php
$connection->beginCache(60); // cache all query results for 60 seconds.
// your db query code here...
$connection->endCache();
```
Fragment Caching
----------------
......
......@@ -158,7 +158,8 @@ used to generate `ETag` header value.
### Database Optimization
Fetching data from database is often the main performance bottleneck in
a Web application. Although using caching may alleviate the performance hit,
a Web application.
Although using [caching](caching.md#Query-Caching) may alleviate the performance hit,
it does not fully solve the problem. When the database contains enormous data
and the cached data is invalid, fetching the latest data could be prohibitively
expensive without proper database and query design.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment