File tree Expand file tree Collapse file tree 1 file changed +2
-12
lines changed Expand file tree Collapse file tree 1 file changed +2
-12
lines changed Original file line number Diff line number Diff line change 88namespace yii \redis ;
99
1010use Yii ;
11- use yii \base \ InvalidConfigException ;
11+ use yii \di \ Instance ;
1212
1313/**
1414 * Redis Cache implements a cache application component based on [redis](http://redis.io/) key-value store.
@@ -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 /**
You can’t perform that action at this time.
0 commit comments