'deleteCache', ActiveRecord::EVENT_AFTER_UPDATE => 'deleteCache', ActiveRecord::EVENT_AFTER_DELETE => 'deleteCache', ]; } public function deleteCache() { foreach ($this->cache_key as $id){ if( isset($this->owner->id) ){ $key = str_replace( '##', $this->owner->id, $id ); }else{ $key = str_replace( '##', '', $id ); } Yii::$app->cache->delete($key); } } }