2012-10-04 137 views
1

我們的項目使用HttpRuntime.Cache.GetHttpRuntime.Cache.Insert來存儲和檢索緩存中的數據。在sql server數據庫中存儲asp.net緩存

是否可以將此緩存存儲在SQL服務器數據庫中?

數據我指的是各種不同的對象類型。

+0

那麼我認爲這是possible..but我想知道這將是多麼有效使用從數據庫高速緩存信息.. –

回答

2

HttpRuntime緩存綁定到當前應用程序的appdomain,您可以控制它的存儲方式。它在緩存上進行智能管理,例如在內存不足時緩存中的生命週期結束之前清除對象。在內存中使用緩存的主要目的是實時快速訪問緩存對象。您無法控制數據的存儲位置或方式。

如果您有理由將數據存儲在流程之外,那麼您可以實施自己的緩存。

public class DatasetStore : MarshalByRefObject 
{ 
    // A hash table-based data store 
    private Hashtable htStore = new Hashtable(); 
    //Returns a null lifetime manager so that GC won't collect the object 
    public override object InitializeLifetimeService() { return null; } 

    // Your custom cache interface 
} 

例如,您可以在多個應用程序域之間共享此緩存。

MSDN Understanding Caching Technologies