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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:46:34+00:00 2026-05-20T04:46:34+00:00

My question is about best practices for caching database updates in Django. I’m writing

  • 0

My question is about best practices for caching database updates in Django.

I’m writing a ticketing system. I have a Ticket model and an Update model. Each time a user adds an update to a ticket, an Update is created and linked as foreign key to the Ticket.

I have a TicketDetail view, that shows the Ticket description and the associated Updates. Users can add an Update from this view. I’ve enabled site-wide caching with memcached.

If a user adds an update and then reload this view, they won’t see the update for a while. I get why, because I need to enable per-view caching, and turn it off for this view.

But to enjoy the full speed of caching, what I’d really like to be able to do is enable caching for this view, but invalidate the cache as soon as a user makes an update.

Is there a straightforward way to do this? Thanks much!

  • 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-20T04:46:34+00:00Added an answer on May 20, 2026 at 4:46 am

    There are some issues when using memcached for invalidating/updating stale data due to race conditions, which one of the main Johnny Cache backends relies on. In your particular case, say you have 10 updates in total and then two different users in two separate processes create a ticket update. It’s quite possible that you end up displaying only 11 updates to both, even though there are 12 in total: one of them is going to end up with a serious case of WTF?

    That’s the kind of problem you’re going to have with any model/queryset invalidation solution if memcached is your store. Your not joining a lot of rows from several different tables, so this shouldn’t be considered as an expensive query–you could probably just rely on the database.

    But not understanding the full extent of the work your doing, it would be improper for me to suggest such a thing. What I would suggest, though, is that you take a look at the possibilities of using mongoDB, Tokyo Cabinet or Redis as a cache replacement for memcached, in situations where you need to have fine-grained control over updating critical user data.

    Another thing you can do is to have all requests that update such data routed through an instance of your application that runs in a single process exclusively. This would completely alleviate any update contention on memcached and it’s viable for applications where reads greatly outperform writes, although I can see how this can quickly become a maintenance nightmare for developers.

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

Sidebar

Related Questions

I have a question about best practices in Java. I'm writing a class, which
I have a question about the proper, best way to manage the model. I
I have posted a question about multilanguage database design here, [] What are best
I have a question about best practices with the Module Design Pattern. The code
I have a question about best practices for Ruby variable-scope using class_eval . In
Just a question about best-practices when upgrading an existing database. Assuming there will be
I have a question about best practices related to de-normalization or table hierarchy relationships.
This is a question about sass best practices. Lets say I have a _colors.scss
I have a question about best C++ coding practices. I noticed that for almost
This is more a question about best practices. I have a view with many

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.