开发者

Re-gain access to memory in a thread in Ruby?

开发者 https://www.devze.com 2023-01-31 07:23 出处:网络
In Ruby, is there a way to spin off a thread, store a variable inside, and then come back later, access the thread, and access the variable inside the thread?

In Ruby, is there a way to spin off a thread, store a variable inside, and then come back later, access the thread, and access the variable inside the thread?

Basically I need to store resources in some common memory pool. These can't be serialized or stored in Memcached. The problem I am facing is that I want to persist an FTP connection object across AJAX calls. I need to regain access to the connection object on t开发者_运维技巧he server-side end of multiple AJAX calls.


I ended up making this work using global variables (eg. $my_global). I have a ConnectionPooler singleton class which manages connections stored in a hash. Easy as pie.

0

精彩评论

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