Redis Cache requires redis version 2.6.12 or higher to work properly. It needs to be configured with a redis Connection that is also configured as an application component. By default it will use the redis application component. See Cache manual for common cache operations that redis Cache supports. Unlike the Cache, redis Cache allows the expire parameter of [[set]], [[add]], [[mset]] and [[madd]] to be a floating point number, so you may specify the time in milliseconds (e.g. 0.1 will be 100 milliseconds). To use redis Cache as the cache application component, configure the application as follows, ~~~ [ 'components' => [ 'cache' => [ 'class' => 'yii\redis\Cache', 'redis' => [ 'hostname' => 'localhost', 'port' => 6379, 'database' => 0, ] ], ], ] ~~~ Or if you have configured the redis Connection as an application component, the following is sufficient: ~~~ [ 'components' => [ 'cache' => [ 'class' => 'yii\redis\Cache', 'redis' => 'redis' // id of the connection application component ], ], ] ~~~
Since: 2.0
Author: Carsten Brandt (mail@cebe.cc)
Inheritance: extends yii\caching\Cache
Beispiel #1
0
    $base['components']['classes'] = ['class' => ClassManager::className()];
}
if (!isset($base['components']['db'])) {
    $base['components']['db'] = (include 'database.php');
}
if (!isset($base['components']['collectors'])) {
    $collectorsConfigPath = CANIS_APP_CONFIG_PATH . DIRECTORY_SEPARATOR . 'modules.php';
    if (file_exists($collectorsConfigPath)) {
        $base['components']['collectors'] = (include $collectorsConfigPath);
    } else {
        $base['components']['collectors'] = (include 'collectors.php');
    }
}
if (!isset($base['components']['cache'])) {
    if (isset($base['components']['redis'])) {
        $base['components']['cache'] = ['class' => RedisCache::className()];
    } else {
        $base['components']['cache'] = ['class' => DummyCache::className()];
    }
}
if (!isset($base['components']['fileCache'])) {
    $base['components']['fileCache'] = ['class' => FileCache::className()];
}
if (!isset($base['components']['gk'])) {
    $base['components']['gk'] = ['class' => Gatekeeper::className(), 'authority' => ['type' => 'Individual']];
}
if (class_exists('cascade\\models\\User')) {
    $base['components']['user'] = ['class' => 'canis\\web\\User', 'enableAutoLogin' => false, 'identityClass' => 'cascade\\server\\models\\User', 'loginUrl' => ['/user/login']];
}
if (!isset($base['components']['fileStorage'])) {
    $base['components']['fileStorage'] = ['class' => FileStorage::className()];