Twilio Functions - Memory and Database

泪湿孤枕 提交于 2020-01-06 06:05:16

问题


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

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

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

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.

Any help greatly appreciated!


回答1:


Twilio developer evangelist here.

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

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.

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.

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.



来源:https://stackoverflow.com/questions/45320603/twilio-functions-memory-and-database

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!