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.
精彩评论