Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace yii\redis;

use Yii;
use yii\base\InvalidConfigException;
use yii\di\Instance;

/**
* Redis Cache implements a cache application component based on [redis](http://redis.io/) key-value store.
Expand Down Expand Up @@ -76,17 +76,7 @@ class Cache extends \yii\caching\Cache
public function init()
{
parent::init();
if (is_string($this->redis)) {
$this->redis = Yii::$app->get($this->redis);
} elseif (is_array($this->redis)) {
if (!isset($this->redis['class'])) {
$this->redis['class'] = Connection::className();
}
$this->redis = Yii::createObject($this->redis);
}
if (!$this->redis instanceof Connection) {
throw new InvalidConfigException("Cache::redis must be either a Redis connection instance or the application component ID of a Redis connection.");
}
$this->redis = Instance::ensure($this->redis, Connection::className());
}

/**
Expand Down