简体   繁体   English

我应该如何使用delay_job?

[英]How should I be using delayed_job?

I've read the docs , but I'm unsure how to integrate it into my application. 我已经阅读了文档 ,但不确定如何将其集成到我的应用程序中。 Currently I have a user input a video url, I take that url and make it a link in the view. 目前,我有一个用户输入视频网址,我将该网址设为视图中的链接。 Then I use the Embedly API to find that link and replace it with an embedded video, thumbnail, and title. 然后,我使用Embedly API查找该链接,并将其替换为嵌入式视频,缩略图和标题。 However, this process takes a bit too long, so I'm thinking of using delayed_job to speed up this process. 但是,此过程花费的时间太长,因此我正在考虑使用delay_job来加快此过程。 How should I go about doing this? 我应该怎么做呢? I'd like to also save the dynamically generated title returned from the Embedly API into my database so users can edit it later. 我还要将从Embedly API返回的动态生成的标题保存到我的数据库中,以便用户以后可以对其进行编辑。

DJ jobs can be anything. DJ工作可以是任何事情。 Did you read the DJ tutorial? 您读过DJ教程了吗? If you have a Video model, use an after_save callback that calls a function, say, generate_video_widget(), via DJ, like so: 如果您具有视频模型,请使用after_save回调通过DJ调用一个函数,例如generate_video_widget(),如下所示:

self.delay.generate_video_widget() self.delay.generate_video_widget()

It's up to you to implement generate_video_widget() to do the things you need it to do. 由您决定要实现generate_video_widget()来完成您需要做的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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