* Cache implements a cache application component by storing cached data in a MongoDB.
...
...
@@ -61,12 +62,7 @@ class Cache extends \yii\caching\Cache
publicfunctioninit()
{
parent::init();
if(is_string($this->db)){
$this->db=Yii::$app->get($this->db);
}
if(!$this->dbinstanceofConnection){
thrownewInvalidConfigException($this->className()."::db must be either a MongoDB connection instance or the application component ID of a MongoDB connection.");
* Session extends [[\yii\web\Session]] by using MongoDB as session data storage.
...
...
@@ -55,13 +56,8 @@ class Session extends \yii\web\Session
*/
publicfunctioninit()
{
if(is_string($this->db)){
$this->db=Yii::$app->get($this->db);
}
if(!$this->dbinstanceofConnection){
thrownewInvalidConfigException($this->className()."::db must be either a MongoDB connection instance or the application component ID of a MongoDB connection.");