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 8093537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:31:25+00:00 2026-06-05T20:31:25+00:00

I am building a web application (in Django, though this isn’t a Django-specific question).

  • 0

I am building a web application (in Django, though this isn’t a Django-specific question). I will have a number of users and they will each have an account balance which will be incremented each time they deposit money with me (via PayPal) and decremented each time they use my application’s API.

I am trying to decide which method would be more appropriate:

  1. Store the balance along with the user as a single integer field. When money comes in, this field is added to. When it goes out, it is subtracted from. Simple, but prone to errors.
  2. Generate the balance on the fly (with caching presumably) adding up all the payments and charges the user has made. A touch more complicated and slower however less prone to errors.

So, which is best or is there another way of doing it?

  • 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-06-05T20:31:26+00:00Added an answer on June 5, 2026 at 8:31 pm

    My opinion is that the first option is less prone to errors than the second. When you start relying on caching for that pretty important value you have to deal with cache synchronization. Obviously every time the users balance changes, you need to invalidate the cache and make sure that any read requests will be 100% accurate. If you do go the cache route, you just have to make sure that extra layer is very well coordinated.

    What I suggest is that you store both a transaction history, and a balance total. The act of making a transaction needs to be atomic so that both the transaction history is made and the update of the balance total is executed, before anything else can read it. You then always have the option of reconciling the balance to the history, or reading and adding directly from the history.

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

Sidebar

Related Questions

I am building a web application that will need to allow users to save
I'm building a web application (in Django) that will accept a search criteria and
I'm building a web application where I have 2 sets of users (students and
I'm building a web application that will have access to PeopleSoft's database via jdbc.
I am building a web application in django 1.4 which I have to deploy
I am building a web application and have been told that using object oriented
I'm building from scratch a web application that is not trivial (have some algorithms
I'm building a web application which will include functionality that takes MS Word (and
I am building a web application on Google App Engine that requires users to
I'm building a simple live chat into a web application running on Django, but

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.