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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:54:27+00:00 2026-05-31T03:54:27+00:00

Now that Stack Overflow uses redis, do they handle cache invalidation the same way?

  • 0

Now that Stack Overflow uses redis, do they handle cache invalidation the same way? i.e. a list of identities hashed to a query string + name (I guess the name is some kind of purpose or object type name).

Perhaps they then retrieve individual items that are missing from the cache directly by id (which bypasses a bunch of database indexes and uses the more efficient clustered index instead perhaps). That’d be smart (the rehydration that Jeff mentions?).

Right now, I’m struggling to find a way to pivot all of this in a succinct way. Are there any examples of this kind of thing that I could use to help clarify my thinking prior to doing a first cut myself?

Also, I’m wondering where the cutoff is between using a .net cache (System.Runtime.Caching or System.Web.Caching) and going out and using redis. Or is Redis just hands down faster?

Here’s the original SO question from 2009:

https://meta.stackexchange.com/questions/6435/how-does-stackoverflow-handle-cache-invalidation

A couple of other links:

https://meta.stackexchange.com/questions/69164/does-stackoverflow-use-caching-and-if-so-how/69172#69172

https://meta.stackexchange.com/questions/110320/stack-overflow-db-performance-and-redis-cache

  • 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-31T03:54:28+00:00Added an answer on May 31, 2026 at 3:54 am

    I honestly can’t decide if this is a SO question or a MSO question, but:

    Going off to another system is never faster than querying local memory (as long as it is keyed); simple answer: we use both! So we use:

    • local memory
    • else check redis, and update local memory
    • else fetch from source, and update redis and local memory

    This then, as you say, causes an issue of cache invalidation – although actually that isn’t critical in most places. But for this – redis events (pub/sub) allow an easy way to broadcast keys that are changing to all nodes, so they can drop their local copy – meaning: next time it is needed we’ll pick up the new copy from redis. Hence we broadcast the key-names that are changing against a single event channel name.

    Tools: redis on ubuntu server; BookSleeve as a redis wrapper; protobuf-net and GZipStream (enabled / disabled automatically depending on size) for packaging data.

    So: the redis pub/sub events are used to invalidate the cache for a given key from one node (the one that knows the state has changed) immediately (pretty much) to all nodes.

    Regarding distinct processes (from comments, “do you use any kind of shared memory model for multiple distinct processes feeding off the same data?”): no, we don’t do that. Each web-tier box is only really hosting one process (of any given tier), with multi-tenancy within that, so inside the same process we might have 70 sites. For legacy reasons (i.e. “it works and doesn’t need fixing”) we primarily use the http cache with the site-identity as part of the key.

    For the few massively data-intensive parts of the system, we have mechanisms to persist to disk so that the in-memory model can be passed between successive app-domains as the web naturally recycles (or is re-deployed), but that is unrelated to redis.

    Here’s a related example that shows the broad flavour only of how this might work – spin up a number of instances of the following, and then type some key names in:

    static class Program
    {
        static void Main()
        {
            const string channelInvalidate = "cache/invalidate";
            using(var pub = new RedisConnection("127.0.0.1"))
            using(var sub = new RedisSubscriberConnection("127.0.0.1"))
            {
                pub.Open();
                sub.Open();
    
                sub.Subscribe(channelInvalidate, (channel, data) =>
                {
                    string key = Encoding.UTF8.GetString(data);
                    Console.WriteLine("Invalidated {0}", key);
                });
                Console.WriteLine(
                        "Enter a key to invalidate, or an empty line to exit");
                string line;
                do
                {
                    line = Console.ReadLine();
                    if(!string.IsNullOrEmpty(line))
                    {
                        pub.Publish(channelInvalidate, line);
                    }
                } while (!string.IsNullOrEmpty(line));
            }
        }
    }
    

    What you should see is that when you type a key-name, it is shown immediately in all the running instances, which would then dump their local copy of that key. Obviously in real use the two connections would need to be put somewhere and kept open, so would not be in using statements. We use an almost-a-singleton for this.

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

Sidebar

Related Questions

Recently, I read a post on Stack Overflow about finding integers that are perfect
so I want to use this JQuery plugin that Stack Overflow has made available
Hello Stack Overflow i hope you are well today; I have a form that
I'm writing a screen-scraper for Stack Overflow. The bit I'm writing now takes the
Now that I can make useful user controls in WPF (thanks to this stackoverflow
Now that I have decided upon Firebird , with the help of StackOverflow :),
First, why I ask: Now that reputation points on StackOverflow have real value (you
Now that most of the major browsers support full page zoom (at present, the
Now that I know C++ I want to get into desktop application that have
Now that LINQ to SQL is a little more mature, I'd like to know

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.