简体   繁体   中英

Rails Delayed Job Accessing value of background job

In my rails app, i have a timer ticking every second based on which different objects change their state. Thus, i decided to use Observer for this. However, when i ran the observer, i noticed it hung up my entire app until the timer completed. Thus, i was thinking of keeping the timer as a background job using delayed_job.

Now my query is that is there any way to fetch the value of the timer every second and use it for some operations in the controller? Example, if i had a set of images appearing at different times, i would ideally like to fetch this current time from the timer and if timing of the image and the current time matches, the images change. Hence, is it possible to fetch the value like this every second from the background process? If yes, can anyone please elaborate?

Just make your delayed job background process save the timer value and corresponding image link to a table. Then read in that value in your controller and act accordingly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM