A real time web application stack with either couchdb and/or nodejs
I am trying to implement a real time application on an existent web site. It is a kind of quest开发者_开发问答ion and answers application and answers to questions come in every second or so. I would like to notify users when an answer to a question has arrived, and I was thinking at first of using nodejs alone and sending the notification from the php( after it has saved the data in the database) to a nodejs server. A longpoll request from the browser gets relevant updates as soon as these arrive in nodejs.
I however stumbled upon couchdb the other day and have been wondering if my approach could be changed. Is it possible and more scalable to use nodejs with couchdb, or can I ignore the nodejs completely and achieve real time updates with couchdb alone.
Thanks in advance,
Roland.
I have an example of a real-time search in Grasshopper.
https://github.com/tuxychandru/grasshopper/tree/master/examples/realtime_search
You can change itemRepo.js to store the answers in CouchDB instead of directly in memory. If CouchDB is not a must, you can use Redis' publish/subscribe pattern in that example through https://github.com/mranney/node_redis.
Disclaimer: I'm the maintainer of Grasshopper.
精彩评论