Set Transient does nothing

And that exactly how it will work, because that’s what you coded 😉

You set the transient correctly, but…

You put only query arguments in there. And that doesn’t make much sense – it’s just an PHP array that is very easy and quick to create.

And the query itself is executed always – it’s outside the if. So yes – the results of the query are obtained on every request. And because you use rand as orderly, then you get random posts on every request.

If you want to use transients to cache results of query and display the same posts for 10 minutes (or other period), then you’ll have to keep these results in the transient.