Twilio 函数 - 内存和数据库 [英] Twilio Functions - Memory and Database

查看:25
本文介绍了Twilio 函数 - 内存和数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用具有电话号码数组的 Twilio 函数.

I am using a Twilio Function which has an array of phone numbers.

我希望能够将这些电话号码存储在我们可以使用我们的 CRM 编辑的 3rd 方云数据库中.

I would like to be able to store these phone numbers in a 3rd party cloud database which we can edit with our CRM.

然后我会编写另一个 Twilio 函数来检查数据库并使用最新数据更新 Twilio Functions 中的数组.

Then I'd write another Twilio function that will check the database and update the array in Twilio Functions with the latest data.

或者,如果有任何其他方式可以让第一个 Twilio 函数从数据库中获取最新数据并将其存储在内存中,那就太好了.如果可能的话,我想避免为每个请求检查数据库,以便尽可能快地完成该功能.

Alternatively if there is any other way that the first Twilio function could get the latest data from the database and store it in memory that would be great. I'd like to avoid checking the database for every request if possible in order to make the function as fast as possible.

非常感谢任何帮助!

推荐答案

Twilio 开发人员布道者在这里.

Twilio developer evangelist here.

目前,由于 Functions 处于公开测试阶段,因此没有用于 Functions 的 API.因此,您还不能更新函数的环境变量上的函数.

Currently, as Functions is in public beta, there is no API for Functions. So you cannot update Functions on Environment Variables for functions yet.

此外,由于测试版限制,您无法安装 Node 模块,例如数据库驱动程序,因此目前访问远程数据存储并不简单.

Also, due to beta limitations, you are unable to install Node modules, such as database drivers, so accessing remote data stores is currently not straightforward.

不过,您可以从函数内部发出 HTTP 请求.因此,如果您的 CRM 可以在响应 HTTP 请求时返回一个数字列表,那么您就可以通过这种方式获取它们.

You can, from within a Function, make HTTP requests though. So, if your CRM could return a list of numbers in response to an HTTP request, then you could fetch them that way.

就将数据存储在函数的内存中而言,这是不可依赖的.函数是短暂的进程,因此内存是易失的.

In terms of storing data in memory for Functions, this is not to be relied upon. Functions are short lived processes so the memory is volatile.

在您的情况下,由于您使用的是数字列表,因此您可以在第一次调用函数时加载该列表,然后通过 URL 将这些数字传递给剩余的调用,这样您只需在第一次.

In your case, since you use a list of numbers, you could load the list in the first call to your Function and then pass those numbers through the URL for the remaining calls, so that you only need to make a request the first time.

让我知道这是否有帮助.

Let me know if that helps at all.

这篇关于Twilio 函数 - 内存和数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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