Shouldn't you check the type of `$cache` first?