Esempio n. 1
0
        /// <summary>
        /// Construct a new Cache with the specified initial and maximum capacities.
        /// </summary>
        /// <param name="initialSize"></param>
        /// <param name="capacity"></param>
        public Cache(int initialSize, int capacity) : base()
        {
            // Initial size cannot be smaller than 1.
            if (initialSize < 1)
            {
                initialSize = 1;
            }

            // Capacity cannot be smaller than 0.
            // If capacity is 0, there is no maximum size for
            // the cache and it will always grow.
            if (capacity < 0)
            {
                capacity = 0;
            }

            _cacheBacker = new CacheBacker(initialSize);
            _capacity    = capacity;

            // Instantiate the lock.
            _cacheBackerLock = new ReaderWriterLock();
        }