Well, REF will not store the value anywhere.
The transaction - Orchestrator will retry the item when REF is deployed again - without REF also it will retry, meaning, the retry of any queue item/transaction is independent of the REF.
If you have configured Max retries as 5 the transaction item in the queue with the status as failed will be automatically be retried when you deploy the bot again.
This is the short answer, but if you are unclear about how to retry every single activity or a whole workflow in ‘your code’ not from Orch. then you will have to look at options like Retry scope, Global handler or a custom loop in your code for retries.
Hope this answers it.