I'm building a website with Rails which can let user check if some domains have been registered. The logic is designed like this:
- There is a text field on a page let users input some domain names
- When user click
check
button, the input will be post to the server - server get the inputs, create a background task(which will be executed in another process), and return some text like "checking now..." to user immediately
- The background task will post the domain names to another site, get the response, parse it to get useful information, then put data to a globle memory hash (the task takes 3 seconds)
- The page contains "checking now..." has a javascript function, will request to server to get the check result. It runs every 2 seconds until it gets result.
- There is a action in the server side to handle the "check-status request". It checks that Globle memory hash, it found the result, returns it, otherwise return "[]"
(I'm using Rails 2.3.8, delayed_job)
I was a Java developer, this is what I will do in Java. But I found it difficult to hold a "globle memory hash" for "delayed job worker" and "rails", because they are in different processes.
Is my design is impossible in rails? Must I store the checking result to database or something like "memcached"?
And, can these background tasks run in parallel?