Skip to content

Commit aba5ffa

Browse files
committed
Refactored \yii\redis\Cache::init
1 parent 9f36981 commit aba5ffa

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

Cache.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,7 @@ class Cache extends \yii\caching\Cache
7676
public function init()
7777
{
7878
parent::init();
79-
if (is_string($this->redis)) {
80-
$this->redis = Yii::$app->get($this->redis);
81-
} elseif (is_array($this->redis)) {
82-
if (!isset($this->redis['class'])) {
83-
$this->redis['class'] = Connection::className();
84-
}
85-
$this->redis = Yii::createObject($this->redis);
86-
}
87-
if (!$this->redis instanceof Connection) {
88-
throw new InvalidConfigException("Cache::redis must be either a Redis connection instance or the application component ID of a Redis connection.");
89-
}
79+
$this->redis = Instance::ensure($this->redis, Connection::className());
9080
}
9181

9282
/**

0 commit comments

Comments
 (0)