Example #1
0
        public Cache(Func <K, V> retrieveFunction, CacheSettings settings)
        {
            if (settings is null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            _cached    = new ConcurrentDictionary <K, CacheItem <V> >();
            Retrieve   = retrieveFunction;
            _retriever = Retrieve != null ?
                         key => new CacheItem <V>(retrieveFunction(key))
                : default(Func <K, CacheItem <V> >);
            Settings          = settings.Clone();
            _minimumCacheSize = (int)Math.Floor(Settings.MaxCacheSize * 0.9);
        }
Example #2
0
        public object Clone()
        {
            CacheServerConfig config = new CacheServerConfig();

            config.cacheSettings    = CacheSettings != null ? (CacheServerConfigSetting)CacheSettings.Clone() : null;
            config.cacheDeployment  = CacheDeployment != null ? (CacheDeployment)CacheDeployment.Clone() : null;
            config.ConfigID         = ConfigID;
            config.configVersion    = configVersion;
            config.IsRegistered     = this.IsRegistered;
            config.IsRunning        = this.IsRunning;
            config.licenseIsExpired = this.licenseIsExpired;
            config.name             = this.name;
            config._alias           = this._alias;

            return(config);
        }
Example #3
0
        public object Clone()
        {
            CacheServerConfig config = new CacheServerConfig();

            config.cacheSettings    = CacheSettings != null ? (CacheServerConfigSetting)CacheSettings.Clone() : null;
            config.cacheDeployment  = CacheDeployment != null ? (CacheDeployment)CacheDeployment.Clone() : null;
            config.Name             = Name != null ? (string)Name.Clone() : null;
            config.IsRegistered     = this.IsRegistered;
            config.IsRunning        = this.IsRunning;
            config.licenseIsExpired = this.licenseIsExpired;

            return(config);
        }