Yii2缓存组件之数据库查询缓存

查询缓存

查询缓存是一个建立在数据缓存之上的特殊缓存特性。它用于缓存数据库查询的结果。PS:需配置好缓存配置

查询缓存需要一个 [[yii\db\Connection|数据库连接]] 和一个有效的cache应用组件。查询缓存的基本用法如下,假设$db是一个 [[yii\db\Connection]] 实例:

$duration = 60; // 缓存查询结果60秒 
$dependency = ...; // 可选的缓存依赖

$db->beginCache($duration, $dependency); 
// ...这儿执行数据库查询...
$db->endCache();

如你所见,beginCache()和endCache()中间的任何查询结果都会被缓存起来。如果缓存中找到了同样查询的结果,则查询会被跳过,直接从缓存中提取结果。

查询缓存可以用于ActiveRecordDAO

Info: 有些 DBMS (例如:MySQL)也支持数据库服务器端的查询缓存。你可以选择使用任一查询缓存机制。上文所述的查询缓存的好处在于你可以指定更灵活的缓存依赖因此可能更加高效。

来自GitHub Yii2中文文档

Responses
  1. [url=https://cholesterolrem.com/]cheap crestor 40 mg[/url] [url=https://tadalafildrug.com/]800 mg cialis[/url] [url=https://anafranill.com/]anafranil[/url] [url=https://musclerelaxant24.com/]tizanidine 2mg tablet price[/url] [url=https://kamagraorder.com/]kamagra 100 chewable tablets[/url]

    Reply
  2. [url=http://effexorx.com/]effexor 100mg[/url]

    Reply
  3. [url=https://sildenafilsub.com/]buy female viagra pills in india[/url] [url=https://viagrarem.com/]where can i order generic viagra online[/url] [url=https://sildenaviagra.com/]cheap real viagra canada[/url] [url=https://amoxill.com/]amoxicillin 500 mg for sale[/url] [url=https://furosemide3.com/]where to buy lasix online[/url]

    Reply
  4. Hello. nail art video 2019 https://www.youtube.com/watch?v=9f8kZQN27ek nail art vinyl stickers nail art flamant rose

    Reply
  5. [url=https://cafergotm.com/]cafergot over the counter[/url] [url=https://hydroxychloroquine5.com/]hydroxychloroquine sulfate cost[/url] [url=https://ciprofloxacinrx.com/]cipro antibiotic where to buy[/url] [url=https://chloroquinegenuine.com/]chloroquine tablets buy online[/url] [url=https://abilifyaripiprazole.com/]abilify 20[/url] [url=https://smotrin.com/]motrin[/url] [url=https://viagrabb.com/]cheapest sildenafil 100 mg online[/url] [url=https://sildenafilt.com/]online generic sildenafil[/url] [url=https://zoloftm.com/]zoloft 2004[/url] [url=https://effexorxs.com/]effexor 37.5 mg tablets[/url] [url=https://fluoxetinecaps.com/]prozac price in india[/url] [url=https://ciprotab.com/]cipro no prescription[/url] [url=https://hydroxychloroquine2.com/]plaquenil uk price[/url] [url=https://silagrarx.com/]silagra pills[/url] [url=https://trentalgen.com/]trental coupon[/url] [url=https://ahydroxychloroquine.com/]plaquenil 10 mg[/url] [url=https://sildenafil240.com/]sildenafil 100mg tablets for sale[/url] [url=https://cleocingel.com/]clindamycin generic brand[/url] [url=https://chloroquinev.com/]chloroquine 250[/url] [url=https://viagrachem.com/]viagra pharmacy generic[/url]

    Reply
  6. [url=https://lasixfuro.com/]furosemide 20 mg tablet cost[/url]

    Reply