How to make a cached query expire immediately?


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);


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 link