예제 #1
0
 /// <summary>
 /// Initializes CacheCrow and uses secondaryCache as the dormant cache.
 /// </summary>
 /// <param name="secondaryCache">Instance of ISecondaryCache></param>
 /// <param name="size">Count of total entries in Active(in-memory) CacheCrow</param>
 /// <param name="activeCacheExpire">Milli-seconds before each entry in Active CacheCrow is expired</param>
 /// <param name="cleanerSnoozeTime">Milli-seconds before Cleaner cleans Dormant CacheCrow. Note: Cleaner is called after every cleanersnoozetime milli-seconds</param>
 /// <returns>Returns instance of ICacheCrow</returns>
 public static ICacheCrow <K, V> Initialize(ISecondaryCache <K, V> secondaryCache, int size = 1000, int activeCacheExpire = 300000, int cleanerSnoozeTime = 400000)
 {
     if (_cache == null)
     {
         _cache = new CacheCrow <K, V>(size, activeCacheExpire, cleanerSnoozeTime, secondaryCache);
     }
     _cache.LoadCache();
     return(_cache);
 }
 private static ISecondaryCache <K, V> CreateInstance(Type type, double cacheExpireInMilliseconds)
 {
     if (type.IsGenericTypeDefinition)
     {
         type = type.MakeGenericType(typeof(K), typeof(V));
     }
     _secondaryCache = Activator.CreateInstance(type, cacheExpireInMilliseconds) as ISecondaryCache <K, V>;
     return(_secondaryCache);
 }