Jake
Jake

Reputation: 136

Yii2 Multiple caching storage

Is it possible to use two or more caching storage in yii2 framework? 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.

hope someone can help. Thanks!

Upvotes: 2

Views: 1227

Answers (2)

Muhammad Shahzad
Muhammad Shahzad

Reputation: 9652

You can register multiple cache application components. The component named cache is used by default by many cache-dependent classes (e.g. yii\web\UrlManager).

Official link

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

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

Upvotes: 1

Xiaosong Guo
Xiaosong Guo

Reputation: 495

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 ...
 ]

Upvotes: 2

Related Questions