예제 #1
0
        public DefaultDiskCachingProvider(string name,
                                          DiskOptions options,
                                          ILoggerFactory loggerFactory = null)
        {
            this._name    = name;
            this._options = options;
            this._logger  = loggerFactory?.CreateLogger <DefaultDiskCachingProvider>();

            this._cacheKeysMap = new ConcurrentDictionary <string, string>();

            this._cacheStats = new CacheStats();

            this.ProviderName          = _name;
            this.ProviderType          = CachingProviderType.Disk;
            this.ProviderStats         = _cacheStats;
            this.ProviderMaxRdSecond   = _options.MaxRdSecond;
            this.IsDistributedProvider = false;

            _info = new ProviderInfo
            {
                CacheStats            = _cacheStats,
                EnableLogging         = options.EnableLogging,
                IsDistributedProvider = IsDistributedProvider,
                LockMs         = options.LockMs,
                MaxRdSecond    = options.MaxRdSecond,
                ProviderName   = ProviderName,
                ProviderType   = ProviderType,
                SerializerName = options.SerializerName,
                SleepMs        = options.SleepMs
            };

            Init();

            _saveKeyTimer = new Timer(SaveKeyToFile, null, TimeSpan.FromSeconds(10), TimeSpan.FromMinutes(2));
        }
예제 #2
0
        public static EasyCachingOptions UseDisk(this EasyCachingOptions options, IConfiguration configuration, string name = EasyCachingConstValue.DefaultDiskName, string sectionName = EasyCachingConstValue.DiskSection)
        {
            var dbConfig    = configuration.GetSection(sectionName);
            var diskOptions = new DiskOptions();

            dbConfig.Bind(diskOptions);

            void configure(DiskOptions x)
            {
                x.EnableLogging = diskOptions.EnableLogging;
                x.MaxRdSecond   = diskOptions.MaxRdSecond;
                x.DBConfig      = diskOptions.DBConfig;
            }

            return(options.UseDisk(configure, name));
        }
        public DefaultDiskCachingProvider(string name,
                                          DiskOptions options,
                                          ILoggerFactory loggerFactory = null)
        {
            this._name    = name;
            this._options = options;
            this._logger  = loggerFactory?.CreateLogger <DefaultDiskCachingProvider>();

            this._cacheKeysMap = new ConcurrentDictionary <string, string>();

            this._cacheStats = new CacheStats();

            this.ProviderName          = _name;
            this.ProviderType          = CachingProviderType.Disk;
            this.ProviderStats         = _cacheStats;
            this.ProviderMaxRdSecond   = _options.MaxRdSecond;
            this.IsDistributedProvider = false;

            Init();

            _saveKeyTimer = new Timer(SaveKeyToFile, null, TimeSpan.FromSeconds(10), TimeSpan.FromMinutes(2));
        }
예제 #4
0
 public DefaultDiskCachingProvider(string name,
                                   DiskOptions options,
                                   ILoggerFactory loggerFactory = null)
     : this(name, options, null, loggerFactory)
 {
 }