本文整理汇总了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>();
}
示例2: HomeController
public HomeController(IConfigurationRoot configuration, IOptions<OtherSettings> otherSettings, ILogger<HomeController> logger, IMemoryCache memoryCache)
{
_configuration = configuration;
_otherSettings = otherSettings.Value;
_logger = logger;
_memoryCache = memoryCache;
}
示例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.");
}
}
示例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);
}
示例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;
}
示例6: CategoryController
public CategoryController(IGanoolService ganool, IMemoryCache cache, IOptions<Settings> options)
{
setting = options.Value;
this.ganool = ganool;
this.ganool.SiteUrl = BaseUrl;
this.cache = cache;
}
示例7: TokenHelper
public TokenHelper(IMemoryCache cache)
{
if (cache == null) throw new ArgumentNullException(nameof(cache), $"{nameof(cache)} cannot be null");
_cache = cache;
_client = new HttpClient();
}
示例8: ProductsService
public ProductsService(
IMemoryCache memoryCache,
ISignalTokenProviderService<Product> tokenProviderService)
{
_memoryCache = memoryCache;
_tokenProviderService = tokenProviderService;
}
示例9: XmlBlogRepository
public XmlBlogRepository(IHostingEnvironment env,
IMemoryCache memoryCache,
ILoggerFactory loggerFactory)
: base(env, memoryCache)
{
Logger = loggerFactory.CreateLogger<XmlBlogRepository>();
}
示例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;
}
示例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)"));
}
}
});
}
示例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);
}
示例13: InMemoryStorage
public InMemoryStorage()
{
var builder = new ServiceCollection();
builder.AddMemoryCache();
var provider = builder.BuildServiceProvider();
_memoryCache = (IMemoryCache)provider.GetService(typeof(IMemoryCache));
}
示例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;
}
示例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;
}