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

  • Home
  • SEARCH
  • 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 6727089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:00:24+00:00 2026-05-26T10:00:24+00:00

Does active record have issues with stale data, or will it happily perform the

  • 0

Does active record have issues with stale data, or will it happily perform the update regardless?

Say I save my user record in memcached, and then a background job updates the same user record , so now memcached has an older version of the user record.

Now in my web application, I get the user record from memcached, and update a property and then save it, will it throw an exception because the user record isn’t the most up to date?

  • 1 1 Answer
  • 0 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-26T10:00:25+00:00Added an answer on May 26, 2026 at 10:00 am

    ActiveRecord’s internal tracking system should only update fields that have been modified since it was last saved, so if you update field A and the background job updates field B then there should be no conflicts.

    You have issues when you’re using counters, though. If you have counter C that was cached as 10, but is actually 12 after the background job, and you want to add one more, you will save 11, not 13. This is why you should never assign to counters, but instead perform a differential adjustment on them instead.

    This is the wrong way:

    UPDATE things SET foo_count=11;
    

    This is the right way:

    UPDATE things SET foo_count=foo_count+1;
    

    You can do this using the increment method of ActiveRecord.

    The only exception you’ll get is if you’re using the ActiveRecord versioning lock, but that seems more trouble than it’s worth.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application, a user has_many tickets. Unfortunately, the tickets table does not have
I have written a task that will run periodically to recalculate and update the
I have an active record set corresponding to some records and I want to
I'm working with an older version of Rails and ActiveRecord that does not have
Does anyone have any recommendations for implementations of ActiveRecord in PHP? I've been using
I have a process which iterates through a bunch of ActiveRecord models, does some
Where does Rails store data created by saving activerecord objects during tests? I thought
ActiveRecord doesn't seem to cater for record locking and database updates. How does one
I have a method that does a paginated find call like.. 1 coll =
So I have recently migrated to postgresql, and have been having issues with my

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.