コード例 #1
0
 /// <summary>
 /// 初始化一个<see cref="DefaultInMemoryCacheProvider"/>类型的实例
 /// </summary>
 /// <param name="cache">内存缓存</param>
 /// <param name="options">内存缓存选项</param>
 /// <param name="log">日志</param>
 public DefaultInMemoryCacheProvider(IMemoryCache cache, IOptionsMonitor <InMemoryOptions> options,
                                     ILog log = null)
 {
     this._cache         = cache;
     this._options       = options.CurrentValue;
     this._log           = log ?? NullLog.Instance;
     this._cacheKeys     = new ConcurrentHashSet <string>();
     this.CacheStatsInfo = new CacheStatsInfo();
 }
コード例 #2
0
        /// <summary>
        /// 注册默认内存缓存操作
        /// </summary>
        /// <param name="services">服务集合</param>
        public static void AddDefaultInMemoryCache(this IServiceCollection services)
        {
            var option = new InMemoryOptions();

            services.AddDefaultInMemoryCache(x =>
            {
                x.CacheProviderType = option.CacheProviderType;
                x.MaxRdSecond       = option.MaxRdSecond;
                x.Order             = option.Order;
            });
        }
コード例 #3
0
        /// <summary>
        /// 注册默认内存缓存操作。使用缓存工厂,实现混合缓存
        /// </summary>
        /// <param name="services">服务集合</param>
        /// <param name="providerName">提供程序名称</param>
        public static void AddDefaultInMemoryCacheWithFactory(this IServiceCollection services,
                                                              string providerName = CacheConst.DefaultInMemoryName)
        {
            var option = new InMemoryOptions();

            services.AddDefaultInMemoryCacheWithFactory(providerName, x =>
            {
                x.CacheProviderType = option.CacheProviderType;
                x.MaxRdSecond       = option.MaxRdSecond;
                x.Order             = option.Order;
            });
        }