开发者

Shared array in rails ruby threads on Nginx

I am using ruby 1.8.7 and rails 2.3.8 and my problem is as follows:-

I have to call 6 different web services via AJAX to get results and in the end all of the results are populated in one global array. Results from these web services are returned usually at random times ( all of these web services usually return results within 6 to 15 seconds).

I am using one global array say @@cars to save the results generated. Whenever, one of the ajax call finish开发者_开发百科es its processing it finds out the @@cars to be nil.

This works fine locally on the development machine with mongrel but on nginx its creating issues.

Any thoughts?


This is really not what global variables are for and I'm not surprised it's not working reliably when using this technique. You should consider putting the data elsewhere (be it a normal database, or something like redis which would be well suited to simple array storage). That way, the data is less associated to the different threads.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜