How to make a cached query expire immediately?

Hi

I need to expire a cached query at the end of a procedure but couldn’t find a way.

It is the query if it give you better vision:


$model = Poll::getDb()->cache(function ($db) use($id){

			    return Poll::findOne($id);

			},60);

I need to expire the cache after updating an attribute of the model which is a counter and it happens somewhere else in application. Also, I couldn’t find a good way to do it using dependencies.

There’s a better solution to handle Active Record caching in Yii2: My linkhttp://www.yiiframework.com/doc-2.0/guide-tutorial-performance-tuning.html#enable-schema-caching