Yii2 schemaCache配置无法生效
原创在YII2中配置enableSchemaCache减少Schema的读取,从而提升数据库的性能,进而提升系统的整体性能,因此在线上的项目都会设置 enableSchemaCache => true。
'enableSchemaCache' => true,
'schemaCacheDuration' => 3600, // Duration of schema cache.
'schemaCache' => 'redis', // Name of the cache component used to store schema information
和 schemaCache有关的主要是三个参数
enableSchemaCache是否开启schema缓存schemaCacheDurationschema缓存的时间,单位sschemaCache存储schema信息的缓存组件的名称
主要是 schemaCache这个配置,如果你不配置,Yii会找 cache组件,默认情况下是文件缓存的方式,如果,没有redis的效率高,因此 我们会将配置改为 'schemaCache' => 'redis' ,但是只是配置redis还不够,cache还必须实现yii\caching\CacheInterface 接口才可以 正确的配置为
'components' => [
'cache' => [
// 'class' => 'yii\caching\FileCache',
'class' => 'yii\redis\Cache',
'keyPrefix' => 'yiicache_',
],
]
版权声明
所有资源都来源于爬虫采集,如有侵权请联系我们,我们将立即删除
itfan123

