thamtech / yii2-multilevel-cache
Yii2的多级缓存组件
v0.1.0
2020-06-05 05:17 UTC
Requires
- php: >=5.6.0
- yiisoft/yii2: >=2.0.14 <2.1
Requires (Dev)
- phpunit/phpunit: ^4.1 || ^5.0
This package is auto-updated.
Last update: 2024-09-10 04:25:15 UTC
README
多级缓存是一个Yii2缓存组件,支持多级缓存。
将快速、本地的缓存组件,如ArrayCache配置为level1
缓存,将较慢的缓存组件,如FileCache配置为level2
缓存。多级缓存组件将自动首先检查level1
缓存,只有当level1
缓存未命中时,才会检查level2
缓存并将结果填充到level1
缓存中。
安装
安装此扩展的首选方式是通过composer。
php composer.phar require --prefer-dist thamtech/yii2-multilevel-cache
或者在您的composer.json
文件的require
部分添加:
"thamtech/yii2-multilevel-cache": "*"
使用方法
应用程序配置示例
<?php 'components' => [ 'cache' => [ 'class' => 'thamtech\caching\multilevel\BiLevelCache', 'level1' => [ 'class' => 'yii\caching\ArrayCache', 'serializer' => false, ], 'level2' => [ 'class' => 'yii\caching\FileCache', ], ], ],