Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 852069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:32:00+00:00 2026-05-15T07:32:00+00:00

My website is like stackoverflow, there are many questions. I want to record how

  • 0

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.

If a user visits 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 this information in the database because the records will be huge. So, I would like to keep the information in memory and only persist the number to the database every 10 minutes.

I have searched about “cache” in Rails, but I haven’t found an example. I would like a simple sample of how to do this, thanks for help~

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T07:32:01+00:00Added an answer on May 15, 2026 at 7:32 am

    This article is pretty amazing – if you have the opportunity to use Memcache I think it would help you greatly: http://www.ridingtheclutch.com/2009/01/08/cache-anything-easily-with-rails-and-memcached.html

    if you could do something like:

    if CACHE.get(key) >= 10:
      send to db
      CACHE.set(key, 0, 1.hour)
    else:
      newcount = CACHE.get(key) + 1
      CACHE.set(key, newcount, 1.hour)
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From this question:- https://stackoverflow.com/questions/1342611/is-there-a-webservice-api-to-grab-a-screenshot-of-another-website and some other questions/google I got some results like:-- http://www.bitpixels.com/
I have virtually the same question as https://stackoverflow.com/questions/3300504/finding-out-all-websites-hosted-by-a-webhosting-service ... I'm trying to get shared
Hello wonderful stackoverflow users. I have a question about url loading. In many browsers
I want to develop a anonymous chat website like http://omgele.com . I know that
Im Making a question for a website and would like the the correct /
While attempting to build a website, i have gone through many online tutorials. Thanks
I am developing a website that implements a feature for posts like Stackoverflow's +1
Something that has been bugging me since I read an answer on another stackoverflow
I am building a chat feature inside a website, something like stackoverflow chat but
I have browsed StackOverflow and found a couple questions/answers that are close but not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.