SPCacheConfig Class
Helper class for managing object caches.
Inheritance Hierarchy
System.Object
Microsoft.Office.Server.ObjectCache.SPCacheConfig
Namespace: Microsoft.Office.Server.ObjectCache
Assembly: Microsoft.Office.Server (in Microsoft.Office.Server.dll)
Syntax
'Declaration
Public Class SPCacheConfig
'Usage
Dim instance As SPCacheConfig
public class SPCacheConfig
Remarks
This is an optional wrapper class that can be used to initialize instances of SPCache. The following sample demonstrates how to create and remove caches with this object.
static SPCacheConfig cacheConfig = new SPCacheConfig();
internal static CacheParameter[] CacheParameters = new CacheParameter[]
{
// DataCache
new CacheParameter(ServiceName,
DataCache,
0xfffff,
PriorityType.High,
new TimeSpan(0,60,0))
};
internal const string ServiceName = "CacheAppStressTest";
internal const string DataCache = "CacheAppStressTest.Data";
static void Main(string[] args)
{
byte priority = 0;
byte numThreads = 1;
CacheParameters[0].lifetime = new TimeSpan(0, (int)duration, 0);
CacheParameters[0].priority = (PriorityType)priority;
cacheConfig.AddCaches(CacheParameters);
SPCache.Cache.Put(DataCache, new SPCachedObject("Test", new TestClass("some data"), null, new TimeSpan(1, 0, 0)));
SPCache.Cache.Get(DataCache, "Test");
SPCache.Cache.Delete(DataCache, "Test");
Console.WriteLine("CacheHits={0}\r\nReads={1}\r\nCount={2}\r\nSizeBytes={3}\r\nHitRatio={4}",
SPCache.Cache.TotalCacheHits, SPCache.Cache.TotalReadAttempts, SPCache.Cache.Count, SPCache.Cache.UsedBytes, SPCache.Cache.HitRatio);
cacheConfig.RemoveCaches(CacheParameters);
}
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.