Answers for "What is the best way to lock cache in asp.net?"

C#
0

What is the best way to lock cache in asp.net?

private static object ThisLock = new object();

public string GetFoo()
{

  // try to pull from cache here

  lock (ThisLock)
  {
    // cache was empty before we got the lock, check again inside the lock

    // cache is still empty, so retreive the value here

    // store the value in the cache here
  }

  // return the cached value here

}
Posted by: Guest on July-30-2021

Code answers related to "What is the best way to lock cache in asp.net?"

C# Answers by Framework

Browse Popular Code Answers by Language