static CachingEngine() { _systemCachePool = new CachePool( "System" ); _tenantCachePools = new Dictionary<string, CachePool>(); _genericCaches = new Dictionary<string, ObjectCache>(); //int numSecondToRun = 60; // run every minute // _cachePruningTimer = new Timer( new TimerCallback( pruneRegisteredCaches ), null, 1000, numSecondToRun * 1000 ); }
/// <summary> /// Empty out the entire cache /// </summary> public static void Flush() { SystemCachePool = new CachePool( "System" ); TenantCachePools = new Dictionary<string, CachePool>(); // SystemLevel.Singleton = Factory.Create<SystemLevel>(); // recreate the system level! }
/// <summary> /// Gets the tenant cache for a given tenant /// </summary> /// <param name="tenantGuid"></param> /// <param name="cacheName"></param> /// <returns></returns> public static ObjectCache GetTenantCache( string tenantGuid, string cacheName ) { CachePool cp; if ( tenantGuid == null ) return null; if ( TenantCachePools.TryGetValue( tenantGuid, out cp ) ) return cp.GetCache( cacheName ); cp = new CachePool( "Tenant" ); // we have to add the pool while (TitanContext.IsInitializing) // wait, if we're initializing { Thread.Sleep(1000); } TenantCachePools.Add( tenantGuid, cp ); return cp.GetCache( cacheName ); }