private ObjectCacheSettings(ObjectCacheSettings other)
 {
     this.CacheLimit     = other.CacheLimit;
     this.IdleTimeout    = other.IdleTimeout;
     this.LeaseTimeout   = other.LeaseTimeout;
     this.PurgeFrequency = other.PurgeFrequency;
 }
 public ObjectCache(ObjectCacheSettings settings, IEqualityComparer <TKey> comparer)
 {
     this.settings            = settings.Clone();
     this.cacheItems          = new Dictionary <TKey, Item <TKey, TValue> >(comparer);
     this.idleTimeoutEnabled  = settings.IdleTimeout != TimeSpan.MaxValue;
     this.leaseTimeoutEnabled = settings.LeaseTimeout != TimeSpan.MaxValue;
 }
 private ObjectCacheSettings(ObjectCacheSettings other)
 {
     this.CacheLimit = other.CacheLimit;
     this.IdleTimeout = other.IdleTimeout;
     this.LeaseTimeout = other.LeaseTimeout;
     this.PurgeFrequency = other.PurgeFrequency;
 }
        public ObjectCache(ObjectCacheSettings settings, IEqualityComparer <TKey> comparer)
        {
            Fx.Assert(settings != null, "caller must use a valid settings object");
            this.settings   = settings.Clone();
            this.cacheItems = new Dictionary <TKey, Item>(comparer);

            // idle feature is disabled if settings.IdleTimeout == TimeSpan.MaxValue
            this.idleTimeoutEnabled = (settings.IdleTimeout != TimeSpan.MaxValue);

            // lease feature is disabled if settings.LeaseTimeout == TimeSpan.MaxValue
            this.leaseTimeoutEnabled = (settings.LeaseTimeout != TimeSpan.MaxValue);
        }
 internal ObjectCache<InternalSendMessage.FactoryCacheKey, InternalSendMessage.ChannelFactoryReference> GetFactoryCache()
 {
     if (this.factoryCache == null)
     {
         this.isReadOnly = true;
         lock (this.thisLock)
         {
             this.ThrowIfDisposed();
             if (this.factoryCache == null)
             {
                 ObjectCacheSettings settings = new ObjectCacheSettings {
                     CacheLimit = this.FactorySettings.MaxItemsInCache,
                     IdleTimeout = this.FactorySettings.IdleTimeout,
                     LeaseTimeout = this.FactorySettings.LeaseTimeout
                 };
                 this.factoryCache = new ObjectCache<InternalSendMessage.FactoryCacheKey, InternalSendMessage.ChannelFactoryReference>(settings);
             }
         }
     }
     return this.factoryCache;
 }
 public ObjectCache(ObjectCacheSettings settings) : this(settings, null)
 {
 }
 // factory cache will be created on first usage after which the settings are immutable
 internal ObjectCache<InternalSendMessage.FactoryCacheKey, InternalSendMessage.ChannelFactoryReference> GetFactoryCache()
 {
     if (this.factoryCache == null)
     {
         this.isReadOnly = true;
         lock (thisLock)
         {
             ThrowIfDisposed();
    
             if (this.factoryCache == null)
             {
                 // we don't need to set DisposeItemCallback since InternalSendMessage.ChannelFactoryReference is IDisposable
                 ObjectCacheSettings objectCacheSettings = new ObjectCacheSettings
                 {
                     CacheLimit = this.FactorySettings.MaxItemsInCache,
                     IdleTimeout = this.FactorySettings.IdleTimeout,
                     LeaseTimeout = this.FactorySettings.LeaseTimeout
                 };
                 this.factoryCache = new ObjectCache<InternalSendMessage.FactoryCacheKey, InternalSendMessage.ChannelFactoryReference>(objectCacheSettings);
             }
         }
     }
     return this.factoryCache;
 }