简体   繁体   English

Yii2多重缓存存储

[英]Yii2 Multiple caching storage

Is it possible to use two or more caching storage in yii2 framework? 可以在yii2框架中使用两个或多个缓存存储吗? I already setup a Memcache for my web app but I wanted also to use a FileCache since I will be dealing with a large chunk of data. 我已经为我的Web应用程序设置了Memcache,但是我也想使用FileCache,因为我将处理大量数据。

hope someone can help. 希望有人可以帮忙。 Thanks! 谢谢!

You can set any cache. 您可以设置任何缓存。 Just set it at config file. 只需将其设置在配置文件中即可。

'components' => [
    'cache' => [
        'class' => 'yii\caching\FileCache',
    ],
   'memCache' => [
        'class' => 'MEMCACHE CLASS HERE',
    ],
    .... ANY cache you want ...
 ]

You can register multiple cache application components. 您可以注册多个缓存应用程序组件。 The component named cache is used by default by many cache-dependent classes (eg yii\\web\\UrlManager). 默认情况下,许多依赖缓存的类(例如yii \\ web \\ UrlManager)都使用名为cache的组件。

Official link 官方链接

'components' => [
    'cache' => [
        'class' => 'yii\caching\MemCache',

    ],
   'fileCache' => [
        'class' => 'yii\caching\FileCache',
    ]
   ]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM