Esempio n. 1
0
        public AssociativeCache(
            int way,
            int totalCacheCapacity,
            ICachePolicyFactory <K, V> cachePolicyFactory   = null,
            ICacheSetHashCalculator <K, V> hashSetCacluator = null,
            AppenderSkeleton appender = null)
        {
            this.appender = appender ?? new ConsoleAppender();

            // Implement as a one way cache
            if (way <= 0)
            {
                LoggingUtility.LogData(this.appender, "Number of cache sets cannot be 0 or negative", Level.Fatal);
                throw new ArgumentOutOfRangeException("Number of cache sets cannot be 0 or negative", "way");
            }

            if (totalCacheCapacity <= 0)
            {
                LoggingUtility.LogData(this.appender, "Number of cache sets cannot be 0 or negative", Level.Fatal);
                throw new ArgumentOutOfRangeException("Number of cache sets cannot be 0 or negative", "totalCacheCapacity");
            }

            this.cachePolicyFactory = cachePolicyFactory;
            this.cacheSetLookUp     = new Dictionary <int, CacheSet <K, V> >();
            this.cachePolicyFactory = cachePolicyFactory ?? new LRUPolicyFactory <K, V>();
            this.hashSetCalculator  = hashSetCalculator ?? new DefaultCacheSetHashCalculator <K, V>(way);

            for (int i = 0; i < way; i++)
            {
                this.cacheSetLookUp.Add(i, new CacheSet <K, V>(this.cachePolicyFactory.CreatePolicy(), totalCacheCapacity / way, this.appender));
            }
        }
 protected CacheRoundTripSpecsBase(ICachePolicyFactory cachePolicyFactory)
 {
     CachePolicyFactory = cachePolicyFactory;
 }
 protected CacheRoundTripSpecsAsyncBase(ICachePolicyFactory cachePolicyFactory) : base(cachePolicyFactory)
 {
 }