I am new to ruby and trying to work on the an appli开发者_高级运维cation that uses caching. I have a code that actually wait for an database update and keep polling until it finds specific value.
The problem is I am getting a stale value from model is there any way to force the RVM to take it from db
while !(["success","error"].include? request.status)
request = (Model.find_by_request_id req_id)
puts(request.inspect)
sleep 1
end
Please help
Active waiting in a process is BAD!
Active waiting for some data in a database is VERY BAD!
you should consider using a message queue between your processes.
Have a look at http://gregmoreno.ca/using-rabbitmq-and-amqp-with-ruby/
精彩评论