2 Replies Latest reply on Mar 6, 2009 2:08 PM by memoryerror

    What keeps putForExternalRead from suffering the thundering-

    memoryerror Newbie

      We have code that looks like this:

      Data getSomeData(key)
      Data theData = theCache.get(node, key);

      if (theData == null)
      theData = read the data from database
      theCache.putForExternalRead(node, key, the data from database);

      return theData;

      Now suppose we have a bunch of threads that hit getSomeData at the same time with the same key.

      Will several threads get a null data, read from the database, and do the putForExternalRead, with only the first call to putForExternalRead having any effect?

      It would be desirable not to have to pay the overhead of multiple database reads in this situation.