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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:56:12+00:00 2026-05-25T14:56:12+00:00

One common pattern when caching with Django is to use the current site’s ID

  • 0

One common pattern when caching with Django is to use the current site’s ID in each cache key, in order to, in essence, namespace your keys. The problem I have is that I’d love to be able to delete all values in cache under a namespace (e.g. Delete all cache values for site 45 because they’ve made some fundamental change). The current pattern to dealing with this send signals all over the place, etc. I’ve used the Site.id cache key example because that is a common pattern that others may recognize, but the way I’m using cache for a custom multi-tenant application makes this problem even more profound, so my question: Is there a cache back-end and/or pattern that works well for deleting objects in a namespaced way, or pseudo-namespaced way, that is not extraordinarily expensive (ie, not looping through all possible cache keys for a given namespace, deleting the cache for each)? I would prefer to use memecached, but am open to any solution that works well, plug-in or not.

  • 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-25T14:56:12+00:00Added an answer on May 25, 2026 at 2:56 pm

    It’s generally difficult to delete large categories of keys. A better approach is for each site to have a generation number associated with it. Start the generation at 1. Use the generation number in the cache keys for that site. When you make a fundamental change, or any other time you want to invalidate the entire cache for the site, increment the site’s generation number. Now all cache accesses will be misses, until everything is cached anew. All the old data will still be in the cache, but it will be discarded as it ages, and it isn’t accessed any more.

    This scheme is extremely efficient, since it doesn’t require finding or touching all the old data at all. It can also be generalized to any class of cache contents, it doesn’t have to be per-site.

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

Sidebar

Related Questions

One common pattern I see and use frequently in C++ is to temporarily set
Does anyone know of papers/books/etc. that document patterns for databases? For example, one common
Ever since switching from TABLE-layout to DIV-layout, one common problem remains: PROBLEM : you
I am moving a system from a VB/Access app to SQL server. One common
I've got two web sites (written in c#) which are pretty common: One is
So one of the common tasks that I do as a programmer is debugging
I have a database where one of the common queries is has a where
I have some tables. These tables all have one column in common called 'classified_id':
One of the most common dilemmas I have when commenting code is how to
This is probably one of the most common tasks / problems when programming; You

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.