我应该如何使用delay_job? [英] How should I be using delayed_job?

查看:173
本文介绍了我应该如何使用delay_job?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了文档,但是我不确定如何将其集成到我的应用程序中.目前,我有一个用户输入视频网址,我将该网址设为视图中的链接.然后,我使用Embedly API查找该链接,并将其替换为嵌入式视频,缩略图和标题.但是,此过程花费的时间太长,因此我正在考虑使用 delayed_job 来加快此过程.我应该怎么做呢?我还要将Embedly API返回的动态生成的标题保存到我的数据库中,以便用户以后可以对其进行编辑.

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. However, this process takes a bit too long, so I'm thinking of using delayed_job to speed up this process. 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.

推荐答案

DJ 工作可以是任何东西.您读过DJ教程了吗?如果您具有视频模型,请使用after_save回调通过DJ调用一个函数,例如generate_video_widget(),如下所示:

DJ jobs can be anything. Did you read the DJ tutorial? If you have a Video model, use an after_save callback that calls a function, say, generate_video_widget(), via DJ, like so:

self.delay.generate_video_widget()

self.delay.generate_video_widget()

由您决定要实现generate_video_widget()来完成您需要做的事情.

It's up to you to implement generate_video_widget() to do the things you need it to do.

这篇关于我应该如何使用delay_job?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆