예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MemoryCacheContainer{TKey, TEntity}"/> class.
        /// </summary>
        /// <param name="containerOptions">The container options.</param>
        /// <param name="retrievalOptions">The retrieval options.</param>
        public MemoryCacheContainer(MemoryCacheContainerOptions <TKey> containerOptions, CacheAutoRetrievalOptions <TKey, TEntity> retrievalOptions = null)
            : base(containerOptions, retrievalOptions)
        {
            var capacity = containerOptions?.Capacity;

            Capacity = (capacity.HasValue && capacity.Value > 1) ? capacity : null;
            var equalityComparer = containerOptions?.EqualityComparer ?? EqualityComparer <TKey> .Default;

            container = capacity == null ? new SequencedKeyDictionary <TKey, MemoryCacheItem <TEntity> >(equalityComparer) : new SequencedKeyDictionary <TKey, MemoryCacheItem <TEntity> >(capacity.Value, equalityComparer);
            Statistic = new MemoryCacheStatistic();
        }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CultureBasedMemoryFullEntityCacheContainer{TEntity}"/> class.
 /// </summary>
 /// <param name="containerOptions">The container options.</param>
 /// <param name="retrievalOptions">The retrieval options.</param>
 public CultureBasedMemoryFullEntityCacheContainer(MemoryCacheContainerOptions <Guid> containerOptions, CultureBasedFullEntityCacheAutoRetrievalOptions <TEntity> retrievalOptions)
     : base(containerOptions, retrievalOptions)
 {
 }