Back

How To: keep a variable across multiple queued jobs


Austin Adamson posted 5 days ago

I've come across a situation where my queued jobs are requiring an api token that I get through hitting an auth endpoint. The token that I retrieve has a rather fast expiration which means it will expire before all of the queued jobs will execute; because of this I can't simply retrieve a token and then pass the token into each dispatch. Since each job execution is within isolated executable code, is there anyway to pass some sort of reference to a global variable that would allow me to update the token upon expiration for all subsequent jobs? Or is the only alternative to store the token in a db and reference it from there?

Any ideas would be appreciated.


Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us