How to the view count of a question in momery?
- by Freewind
My website is like stackoverflow, there are many questions. I want to record how many times a question has been visited. I have a column called "view_count" in the question table to save it.
When a user visited a question many times, the view_count should be increased only 1. So I have to record which user has visited which question, and I think it is too much expensive to save them in the database, because the records will be huge. So I want to keep them in the memory, and persistent the number to database every 10 minutes.
I have searched about "cache" of rails, but I haven't found an example. I need an simple sample of how to do this, thanks for help~