Frage

Storing data in Thread-Local Storage or HttpContext.Current.Items, which one is more efficient….?
This is for storing master data/parameters in a web application.
Code for placing data in both method are:

1. System.Web.HttpContext.Current.Items

public static void Add(string pName, object pValue)
{
    System.Web.HttpContext.Current.Items.Add(pName, pValue);
}

2. TLS

public static void Add(string pName, object pValue)
{
    Thread.SetData(Thread.GetNamedDataSlot(pName), pValue);
}


Thanks....

War es hilfreich?

Lösung

If you are considering thread safety, go with Thread-Local Storage. If thread safety not required, then HttpContext.Current option is useful.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top