当前位置: 首页>>代码示例>>C#>>正文


C# IMemoryCache类代码示例

本文整理汇总了C#中IMemoryCache的典型用法代码示例。如果您正苦于以下问题:C# IMemoryCache类的具体用法?C# IMemoryCache怎么用?C# IMemoryCache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IMemoryCache类属于命名空间,在下文中一共展示了IMemoryCache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitializeENodeFramework

        static void InitializeENodeFramework()
        {
            var setting = new ConfigurationSetting
            {
                SqlDefaultConnectionString = ConfigurationManager.AppSettings["connectionString"],
                EnableGroupCommitEvent = false
            };
            var assemblies = new[]
            {
                Assembly.Load("NoteSample.Domain"),
                Assembly.Load("NoteSample.CommandHandlers"),
                Assembly.Load("NoteSample.Commands"),
                Assembly.GetExecutingAssembly()
            };
            _configuration = ECommonConfiguration
                .Create()
                .UseAutofac()
                .RegisterCommonComponents()
                .UseLog4Net()
                .UseJsonNet()
                .RegisterUnhandledExceptionHandler()
                .CreateENode(setting)
                .RegisterENodeComponents()
                .UseSqlServerEventStore()
                .RegisterBusinessComponents(assemblies)
                .InitializeBusinessAssemblies(assemblies)
                .UseEQueue()
                .StartEQueue();

            _commandService = ObjectContainer.Resolve<ICommandService>();
            _memoryCache = ObjectContainer.Resolve<IMemoryCache>();
        }
开发者ID:ivivisoft,项目名称:enode,代码行数:32,代码来源:Program.cs

示例2: HomeController

 public HomeController(IConfigurationRoot configuration, IOptions<OtherSettings> otherSettings, ILogger<HomeController> logger, IMemoryCache memoryCache)
 {
     _configuration = configuration;
     _otherSettings = otherSettings.Value;
     _logger = logger;
     _memoryCache = memoryCache;
 }
开发者ID:niros2,项目名称:PublicRepo,代码行数:7,代码来源:HomeController.cs

示例3: DefaultCommandExecutor

        public DefaultCommandExecutor(
            IProcessingCommandCache processingCommandCache,
            ICommandAsyncResultManager commandAsyncResultManager,
            ICommandHandlerProvider commandHandlerProvider,
            IAggregateRootTypeProvider aggregateRootTypeProvider,
            IMemoryCache memoryCache,
            IRepository repository,
            IRetryCommandService retryCommandService,
            IEventStore eventStore,
            IEventPublisher eventPublisher,
            IEventPersistenceSynchronizerProvider eventPersistenceSynchronizerProvider,
            ICommandContext commandContext,
            ILoggerFactory loggerFactory)
        {
            _processingCommandCache = processingCommandCache;
            _commandAsyncResultManager = commandAsyncResultManager;
            _commandHandlerProvider = commandHandlerProvider;
            _aggregateRootTypeProvider = aggregateRootTypeProvider;
            _memoryCache = memoryCache;
            _repository = repository;
            _retryCommandService = retryCommandService;
            _eventStore = eventStore;
            _eventPublisher = eventPublisher;
            _eventPersistenceSynchronizerProvider = eventPersistenceSynchronizerProvider;
            _commandContext = commandContext;
            _trackingContext = commandContext as ITrackingContext;
            _logger = loggerFactory.Create(GetType().Name);

            if (_trackingContext == null)
            {
                throw new Exception("command context must also implement ITrackingContext interface.");
            }
        }
开发者ID:hjlfmy,项目名称:enode,代码行数:33,代码来源:DefaultCommandExecutor.cs

示例4: DefaultCommitEventService

 /// <summary>Parameterized constructor.
 /// </summary>
 /// <param name="waitingCommandService"></param>
 /// <param name="aggregateRootTypeCodeProvider"></param>
 /// <param name="aggregateRootFactory"></param>
 /// <param name="eventStreamConvertService"></param>
 /// <param name="eventSourcingService"></param>
 /// <param name="memoryCache"></param>
 /// <param name="aggregateStorage"></param>
 /// <param name="retryCommandService"></param>
 /// <param name="eventStore"></param>
 /// <param name="eventPublisher"></param>
 /// <param name="actionExecutionService"></param>
 /// <param name="eventSynchronizerProvider"></param>
 /// <param name="loggerFactory"></param>
 public DefaultCommitEventService(
     IWaitingCommandService waitingCommandService,
     IAggregateRootTypeCodeProvider aggregateRootTypeCodeProvider,
     IAggregateRootFactory aggregateRootFactory,
     IEventStreamConvertService eventStreamConvertService,
     IEventSourcingService eventSourcingService,
     IMemoryCache memoryCache,
     IAggregateStorage aggregateStorage,
     IRetryCommandService retryCommandService,
     IEventStore eventStore,
     IEventPublisher eventPublisher,
     IActionExecutionService actionExecutionService,
     IEventSynchronizerProvider eventSynchronizerProvider,
     ILoggerFactory loggerFactory)
 {
     _waitingCommandService = waitingCommandService;
     _aggregateRootTypeCodeProvider = aggregateRootTypeCodeProvider;
     _aggregateRootFactory = aggregateRootFactory;
     _eventStreamConvertService = eventStreamConvertService;
     _eventSourcingService = eventSourcingService;
     _memoryCache = memoryCache;
     _aggregateStorage = aggregateStorage;
     _retryCommandService = retryCommandService;
     _eventStore = eventStore;
     _eventPublisher = eventPublisher;
     _actionExecutionService = actionExecutionService;
     _eventSynchronizerProvider = eventSynchronizerProvider;
     _logger = loggerFactory.Create(GetType().Name);
 }
开发者ID:key-value,项目名称:enode,代码行数:44,代码来源:DefaultCommitEventService.cs

示例5: DefaultEventService

 public DefaultEventService(
     IJsonSerializer jsonSerializer,
     IScheduleService scheduleService,
     ITypeNameProvider typeNameProvider,
     IMemoryCache memoryCache,
     IAggregateRootFactory aggregateRootFactory,
     IAggregateStorage aggregateStorage,
     IEventStore eventStore,
     IMessagePublisher<DomainEventStreamMessage> domainEventPublisher,
     IOHelper ioHelper,
     ILoggerFactory loggerFactory)
 {
     _eventMailboxDict = new ConcurrentDictionary<string, EventMailBox>();
     _ioHelper = ioHelper;
     _jsonSerializer = jsonSerializer;
     _scheduleService = scheduleService;
     _typeNameProvider = typeNameProvider;
     _memoryCache = memoryCache;
     _aggregateRootFactory = aggregateRootFactory;
     _aggregateStorage = aggregateStorage;
     _eventStore = eventStore;
     _domainEventPublisher = domainEventPublisher;
     _logger = loggerFactory.Create(GetType().FullName);
     _batchSize = ENodeConfiguration.Instance.Setting.EventMailBoxPersistenceMaxBatchSize;
 }
开发者ID:ulswww,项目名称:enode,代码行数:25,代码来源:DefaultEventService.cs

示例6: CategoryController

		public CategoryController(IGanoolService ganool, IMemoryCache cache, IOptions<Settings> options)
	    {
			setting = options.Value;
			this.ganool = ganool;
			this.ganool.SiteUrl = BaseUrl;
			this.cache = cache;
	    }
开发者ID:fakhrulhilal,项目名称:web-crawler,代码行数:7,代码来源:CategoryController.cs

示例7: TokenHelper

        public TokenHelper(IMemoryCache cache)
        {
            if (cache == null) throw new ArgumentNullException(nameof(cache), $"{nameof(cache)} cannot be null");

            _cache = cache;
            _client = new HttpClient();
        }
开发者ID:digipolisantwerp,项目名称:serviceagents_aspnetcore,代码行数:7,代码来源:TokenHelper.cs

示例8: ProductsService

 public ProductsService(
     IMemoryCache memoryCache,
     ISignalTokenProviderService<Product> tokenProviderService)
 {
     _memoryCache = memoryCache;
     _tokenProviderService = tokenProviderService;
 }
开发者ID:cemalshukriev,项目名称:Mvc,代码行数:7,代码来源:ProductsService.cs

示例9: XmlBlogRepository

 public XmlBlogRepository(IHostingEnvironment env,
                             IMemoryCache memoryCache,
                             ILoggerFactory loggerFactory)
     : base(env, memoryCache)
 {
     Logger = loggerFactory.CreateLogger<XmlBlogRepository>();
 }
开发者ID:cnurse,项目名称:Naif.Blog,代码行数:7,代码来源:XmlBlogRepository.cs

示例10: QRCodeMiddleware

 public QRCodeMiddleware(RequestDelegate next, IQRCodeGenerator generator, IMemoryCache cache, ILogger<QRCodeMiddleware> logger)
 {
     this.next = next;
     this.logger = logger;
     this.generator = generator;
     this.cache = cache;
 }
开发者ID:r15h1,项目名称:qrcodr,代码行数:7,代码来源:QRCodeMiddleware.cs

示例11: PriodicallyReadKey

        private void PriodicallyReadKey(IMemoryCache cache, TimeSpan interval)
        {
            Task.Run(async () =>
            {
                while (true)
                {
                    await Task.Delay(interval);

                    if (Random.Next(3) == 0) // 1/3 chance
                    {
                        // Allow values to expire due to sliding refresh.
                        Console.WriteLine("Read skipped, random choice.");
                    }
                    else
                    {
                        Console.Write("Reading...");
                        object result;
                        if(!cache.TryGetValue(Key, out result))
                        {
                            result = cache.Set(Key, "B", _cacheEntryOptions);
                        }
                        Console.WriteLine("Read: " + (result ?? "(null)"));
                    }
                }
            });
        }
开发者ID:TerabyteX,项目名称:Caching,代码行数:26,代码来源:Program.cs

示例12: DefaultCleanAggregateService

 public DefaultCleanAggregateService(IMemoryCache memoryCache, IScheduleService scheduleService)
 {
     TimeoutSeconds = ENodeConfiguration.Instance.Setting.AggregateRootMaxInactiveSeconds;
     _memoryCache = memoryCache;
     _scheduleService = scheduleService;
     _scheduleService.StartTask("CleanAggregates", Clean, 1000, ENodeConfiguration.Instance.Setting.ScanExpiredAggregateIntervalMilliseconds);
 }
开发者ID:ulswww,项目名称:enode,代码行数:7,代码来源:DefaultCleanAggregateService.cs

示例13: InMemoryStorage

 public InMemoryStorage()
 {
     var builder = new ServiceCollection();
     builder.AddMemoryCache();
     var provider = builder.BuildServiceProvider();
     _memoryCache = (IMemoryCache)provider.GetService(typeof(IMemoryCache));
 }
开发者ID:yaozhenfa,项目名称:WebAPIContrib.Core,代码行数:7,代码来源:InMemoryStorage.cs

示例14: SecurityController

 public SecurityController(IMemoryCache cache, ICacheFactoryStore cacheFactoryStore, ToracGolfContext dbContext, IOptions<AppSettings> configuration, ILogger<SecurityController> logger)
 {
     DbContext = dbContext;
     Cache = cache;
     CacheFactory = cacheFactoryStore;
     Configuration = configuration;
     Logger = logger;
 }
开发者ID:dibiancoj,项目名称:ToracGolf,代码行数:8,代码来源:SecurityController.cs

示例15: SettingsController

 public SettingsController(IMemoryCache cache, ICacheFactoryStore cacheFactoryStore, ToracGolfContext dbContext, IAntiforgery antiforgery, IOptions<AppSettings> configuration)
 {
     DbContext = dbContext;
     Cache = cache;
     CacheFactory = cacheFactoryStore;
     Antiforgery = antiforgery;
     Configuration = configuration;
 }
开发者ID:dibiancoj,项目名称:ToracGolf,代码行数:8,代码来源:SettingsController.cs


注:本文中的IMemoryCache类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。