P
P
Pogran2016-07-15 12:38:43
Yii
Pogran, 2016-07-15 12:38:43

How to properly use cache in yii2?

I have a cache for authManager in my settings. In theory, everything is cached now. But confuses the number of requests to the database anyway.
Here's what's in the config now

'authManager' => [
            'class' => 'yii\rbac\DbManager',
            'cache' => 'cache',
            'cacheKey' => '****',
        ],
'db' => [
            'class' => 'yii\db\Connection',
            'enableSchemaCache' => true,
            'dsn' => 'mysql:host=localhost;dbname=***',
            'username' => '***',
            'password' => '***',
            'charset' => 'utf8',
        ],
'cache' => [
            'class' => 'yii\caching\DbCache',
        ],

And here's what's in the debugger prntscr.com/bt6h6d . It turns out 16 requests, and 10 of them are accessing the cache (9 for fetch and one for update). Can I use something like this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kim, 2016-07-15
@kimono

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

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question