How to pass parameters to cache function?

I’m trying to implement a cache system but I’m having problem to pass paramenters fo the cache callable function.


$slug = "test";

$model = MyModel::getDb()->cache(function ($db) {

            return MyModel::find()->with(['something'])->where(['slug' => $slug])->one();


How can I pass the $slug variable to inside the function called on cache()?

function ($db) use ($slug) {

Great!! Thank you very much