public async Task <CommunityGoal> GetAsync(int id, CancellationToken cancellationToken = default) { await _lock.WaitAsync(cancellationToken).ConfigureAwait(false); try { CommunityGoal result; CachingOptions cachingOptions = _cachingOptions.Get(CacheOptionName); if (cachingOptions.Enabled && (result = _cgCache.Get(id)) != null) { _log.LogTrace("Community goal {ID} ({Name}) found in cache", id, result.Name); return(result); } // get from DB _log.LogTrace("Retrieving community goal {ID} from history database", id); result = await _collection.Find(dbData => dbData.ID == id).FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false); if (result != null) { _cgCache.AddOrReplace(result.ID, result, cachingOptions.Lifetime); } return(result); } finally { _lock.Release(); } }
public RedisPlatformMemoryCache(IMemoryCache memoryCache , IConnectionMultiplexer connection , ISubscriber bus , IOptions <CachingOptions> cachingOptions , IOptions <RedisCachingOptions> redisCachingOptions , ILogger <RedisPlatformMemoryCache> log , TelemetryClient telemetryClient ) : base(memoryCache, cachingOptions, log) { _connection = connection; _log = log; _telemetryClient = telemetryClient; _bus = bus; _cachingOptions = cachingOptions.Value; _redisCachingOptions = redisCachingOptions.Value; connection.ConnectionFailed += OnConnectionFailed; connection.ConnectionRestored += OnConnectionRestored; _bus.Subscribe(_redisCachingOptions.ChannelName, OnMessage, CommandFlags.FireAndForget); _log.LogInformation($"{nameof(RedisPlatformMemoryCache)}: subscribe to channel {_redisCachingOptions.ChannelName } current instance:{ ServerId }"); _telemetryClient.TrackEvent("RedisSubscribed", new Dictionary <string, string> { { "channelName", _redisCachingOptions.ChannelName }, { "cacheId", ServerId } }); }
public ActionResult <UserLocationRuleDTO> GetLocationByCampaignAndLocationRuleId(int campaignId, int userLocationRuleId) { if (campaignId < 1 || userLocationRuleId < 1) { return(BadRequest()); } UserLocationRule location = null; if (!_settings.CachingEnabled) { location = _context.Rules .OfType <UserLocationRule>() .SingleOrDefault(c => c.CampaignId == campaignId && c.Id == userLocationRuleId); } else { var options = new CachingOptions(); options.SetAbsoluteExpiration(DateTime.Now.AddMinutes(_settings.MarketingCacheExpirationTimeInMinutes)); location = _context.Rules .OfType <UserLocationRule>() .DeferredSingleOrDefault(c => c.CampaignId == campaignId && c.Id == userLocationRuleId) .FromCache(options); } if (location is null) { return(NotFound()); } return(MapUserLocationRuleModelToDto(location)); }
public static void InitializeTestClass(TestContext testContext) { FileMergeStorageOptions fileMergeStorageOptions = new FileMergeStorageOptions() { MergeResultsStoragePath = "D:\\Temp\\FFRKApi\\MergeResults-{Date}.json" }; IOptions <FileMergeStorageOptions> fileMergeStorageOptionsWrapper = new OptionsWrapper <FileMergeStorageOptions>(fileMergeStorageOptions); CachingOptions cachingOptions = new CachingOptions() { UseCache = "false", ConnectionString = "Placeholder", DefaultTimeToLiveInHours = "2" }; IOptions <CachingOptions> cachingOptionsWrapper = new OptionsWrapper <CachingOptions>(cachingOptions); ApiExternalWebsiteOptions apiExternalWebsiteOptions = new ApiExternalWebsiteOptions() { AltemaCharacterRatingsUrl = "https://altema.jp/ffrk/charahyoka" }; IOptions <ApiExternalWebsiteOptions> apiExternalWebsiteOptionsWrapper = new OptionsWrapper <ApiExternalWebsiteOptions>(apiExternalWebsiteOptions); _fileMergeStorageProviderLogger = new Logger <FileMergeStorageProvider>(new LoggerFactory()); _cacheProviderLogger = new Logger <CacheProvider>(new LoggerFactory()); _altemaCharacterRatingLogicLogger = new Logger <CharacterRatingLogic>(new LoggerFactory()); _cacheProvider = new CacheProvider(cachingOptionsWrapper, _cacheProviderLogger); _mergeStorageProvider = new FileMergeStorageProvider(fileMergeStorageOptionsWrapper, _fileMergeStorageProviderLogger); _enlirRepository = new EnlirRepository(_mergeStorageProvider); _altemaCharacterRatingRepository = new AltemaCharacterRatingWebRepository(apiExternalWebsiteOptionsWrapper); }
public ImageCaching(RequestDelegate next, IImageCacheHelper cacheHelper, CachingOptions options) { _next = next; _options = options; _cacheHelper = cacheHelper; _cacheHelper.InitCacheOptions(_options); }
public async Task <UserData> GetAsync(ulong userID, CancellationToken cancellationToken = default) { await _lock.WaitAsync(cancellationToken).ConfigureAwait(false); try { UserData result; CachingOptions cachingOptions = _cachingOptions.Get(CacheOptionName); if (cachingOptions.Enabled && (result = _userDataCache.Get(userID)) != null) { _log.LogTrace("User data for user {UserID} found in cache", userID); return(result); } // get from DB _log.LogTrace("Retrieving user data for user {UserID} from database", userID); result = await _collection.Find(dbData => dbData.ID == userID).FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false); // if not found, return default data if (result == null) { _log.LogTrace("User data for user {UserID} not found, creating new with defaults", userID); result = new UserData(userID); } _userDataCache.AddOrReplace(result.ID, result, cachingOptions.Lifetime); return(result); } finally { _lock.Release(); } }
public async Task <ActionResult> CreateLocationAsync(int campaignId, [FromBody] UserLocationRuleDTO locationRuleDto) { if (campaignId < 1 || locationRuleDto is null) { return(BadRequest()); } var locationRule = MapUserLocationRuleDtoToModel(locationRuleDto); locationRule.CampaignId = campaignId; await _context.Rules.AddAsync(locationRule); await _context.SaveChangesAsync(); if (_settings.CachingEnabled) { var cache = _context.GetCache(); var options = new CachingOptions(); options.SetAbsoluteExpiration(DateTime.Now.AddMinutes(_settings.MarketingCacheExpirationTimeInMinutes)); await Task.Run(() => cache.Insert(locationRule, out string cacheKey, options)); } return(CreatedAtAction(nameof(GetLocationByCampaignAndLocationRuleId), new { campaignId = campaignId, userLocationRuleId = locationRule.Id }, null)); }
public async Task <ActionResult <List <CampaignDTO> > > GetAllCampaignsAsync() { var campaignList = new List <Campaign>(); if (!_settings.CachingEnabled) { campaignList = await _context.Campaigns.ToListAsync(); } else { var options = new CachingOptions { StoreAs = StoreAs.SeperateEntities }; options.SetAbsoluteExpiration(DateTime.Now.AddMinutes(_settings.MarketingCacheExpirationTimeInMinutes)); campaignList = (await _context.Campaigns.FromCacheAsync(options)).ToList(); } if (campaignList is null) { return(Ok()); } return(MapCampaignModelListToDtoList(campaignList)); }
public async Task <NetflixAccount> GetAsync(CancellationToken cancellationToken = default) { await _lock.WaitAsync(cancellationToken).ConfigureAwait(false); try { CachingOptions cachingOptions = _cachingOptions.Get(CacheOptionName); if (cachingOptions.Enabled && _cachedAccount != null && !_cachedAccount.IsExpired) { _log.LogTrace("Netflix account found in cache"); return(_cachedAccount); } _log.LogDebug("Retrieving Netflix account from database"); NetflixAccount result = await _netflixAccountsCollection.Find(_ => true).FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false); if (result == null) { _log.LogTrace("Netflix account not found, creating default"); result = new NetflixAccount(); } if (cachingOptions.Enabled) { _cachedAccount = new CachedEntity <string, NetflixAccount>(result.Login, result, cachingOptions.Lifetime); } return(result); } finally { _lock.Release(); } }
public async Task <ActionResult <CatalogItem> > ItemByIdAsync(int id) { if (id <= 0) { return(BadRequest()); } CatalogItem item = null; if (!_settings.EFCoreCachingEnabled) { item = await _catalogContext.CatalogItems.SingleOrDefaultAsync(ci => ci.Id == id); } else { var options = new CachingOptions { }; options.SetAbsoluteExpiration(DateTime.Now.AddMinutes(_settings.NCacheAbsoluteExpirationTime)); item = await _catalogContext.CatalogItems.DeferredSingleOrDefault(ci => ci.Id == id).FromCacheAsync(options); } var baseUri = _settings.PicBaseUrl; item.FillProductUrl(baseUri); if (item != null) { return(item); } return(NotFound()); }
/// <summary> /// Adds bound caching options found in the <see cref="IConfiguration"/> /// </summary> /// <param name="collection"></param> /// <param name="configuration"></param> /// <returns></returns> public static IServiceCollection AddCachingOptions(this IServiceCollection collection, IConfiguration configuration) { var options = new CachingOptions(); configuration.GetSection(CachingOptions.Key).Bind(options); return(collection.AddSingleton(options)); }
private async Task AutoClearLoopAsync <TKey, TEntity>(IEntityCache <TKey, TEntity> cache, string optionsName, IBatchingStore store, CancellationToken cancellationToken = default) where TEntity : IEntity <TKey> { CachingOptions options = _cachingOptions.Get(optionsName); if (options.Lifetime < TimeSpan.Zero) { _log.LogDebug("{ServiceName} cache lifetime set to 0 or lower, cache purges disabled", cache.GetType().Name); return; } _log.LogDebug("{ServiceName} starting cache auto-clear loop with rate of {ClearRate}", cache.GetType().Name, options.Lifetime); while (!cancellationToken.IsCancellationRequested) { await Task.Delay(options.Lifetime, cancellationToken).ConfigureAwait(false); // flush batch to prevent data loss store?.FlushBatch(); // find and remove entities from cache IEnumerable <TEntity> expired = cache.Find(e => e.IsExpired(options.Lifetime)); foreach (TEntity entity in expired) { cache.Remove(entity.ID); } _log.LogDebug("{RemovedCount} expired {ServiceName} entities removed from cache", expired.Count(), cache.GetType().Name); } }
public RabbitMqAdapter(RabbitMqOptions rmqOptions, CachingOptions cachingOptions, IBatchContainerSerializer serializer, IStreamQueueMapper mapper, string providerName, ILoggerFactory loggerFactory) { _serializer = serializer; _mapper = mapper; Name = providerName; _rmqConnectorFactory = new RabbitMqOnlineConnectorFactory(rmqOptions, loggerFactory); _cacheFillingTimeout = cachingOptions.CacheFillingTimeout; }
public virtual void Set <T>(string key, T value, CachingOptions options = null) { memoryCache.Set <T>($"{typeof(T).Name}_{key}", value, new MemoryCacheEntryOptions { AbsoluteExpirationRelativeToNow = options.ExpirationPeriod, SlidingExpiration = options.InactivePeriod }); }
internal static CachingOptions ExtractKeyListOptions(CachingOptions options) { CachingOptions nOptions = (CachingOptions)options.Clone(); nOptions.QueryIdentifier = null; nOptions.RemoveResync(); return(nOptions); }
public async Task <ActionResult <PaginatedItemsViewModel <CatalogItem> > > ItemsByTypeIdAndBrandIdAsync(int catalogTypeId, int?catalogBrandId, [FromQuery] int pageSize = 10, [FromQuery] int pageIndex = 0) { var root = (IQueryable <CatalogItem>)_catalogContext.CatalogItems; root = root.Where(ci => ci.CatalogTypeId == catalogTypeId); if (catalogBrandId.HasValue) { root = root.Where(ci => ci.CatalogBrandId == catalogBrandId); } long totalItems = -1L; var itemsOnPage = new List <CatalogItem>(); if (!_settings.EFCoreCachingEnabled) { totalItems = await root .LongCountAsync(); itemsOnPage = await root .Skip(pageSize *pageIndex) .Take(pageSize) .ToListAsync(); } else { var catalogBrandIDString = ""; if (catalogBrandId.HasValue) { catalogBrandIDString = $"{catalogBrandId }"; } var options = new CachingOptions { StoreAs = StoreAs.SeperateEntities }; options.SetAbsoluteExpiration(DateTime.Now.AddMinutes(_settings.NCacheAbsoluteExpirationTime)); totalItems = await root .DeferredLongCount() .FromCacheAsync(options); options.StoreAs = StoreAs.SeperateEntities; itemsOnPage = (await root .Skip(pageSize * pageIndex) .Take(pageSize) .FromCacheAsync(options)).ToList(); } itemsOnPage = ChangeUriPlaceholder(itemsOnPage); return(new PaginatedItemsViewModel <CatalogItem>(pageIndex, pageSize, totalItems, itemsOnPage)); }
public TodoService(IMapper mapper, IUnitOfWork unitOfWork, ITodoRepository repository, IBedrockCache cache, CachingOptions cachingOptions, ILogger <TodoService> logger) : base(mapper, unitOfWork, cache) { this._logger = logger; this._cachingOptions = cachingOptions; this._repository = repository; }
public RockOptions(OptimizationSetting level = OptimizationSetting.Release, CodeFileOptions codeFile = CodeFileOptions.None, SerializationOptions serialization = SerializationOptions.NotSupported, CachingOptions caching = CachingOptions.UseCache, AllowWarnings allowWarnings = AllowWarnings.No) { this.Optimization = level; this.CodeFile = codeFile; this.Serialization = serialization; this.Caching = caching; this.AllowWarnings = allowWarnings; }
/// <summary> /// Returns a new query where the result will be cached base on the <see cref="TimeSpan"/> parameter. /// </summary> /// <typeparam name="T">The type of entity being queried.</typeparam> /// <param name="source">The source query.</param> /// <param name="options">Options how to handle cached query results.</param> /// <returns>A new query where the result set will be cached.</returns> public static IQueryable <T> AsCaching <T>(this IQueryable <T> source, [NotParameterized] CachingOptions options) { Check.NotNull(source, nameof(source)); Check.NotNull(options, nameof(options)); return (source.Provider is EntityQueryProvider ? source.Provider.CreateQuery <T>( Expression.Call( instance: null, method: AsCachingMethodInfo.MakeGenericMethod(typeof(T)), arg0: source.Expression, arg1: Expression.Constant(options))) : source); }
public ProcessPaymentHandler( IAcquiringBank acquiringBank, INowProvider nowProvider, IMemoryCache cache, ILogger logger, CachingOptions cachingOptions, CheckoutPaymentAPIContext context) { _acquiringBank = acquiringBank; _nowProvider = nowProvider; _cache = cache; _logger = logger; _cachingOptions = cachingOptions; _context = context; }
public void InitCacheOptions(CachingOptions cacheOptions) { _options = cacheOptions; _timer = new Timer() { Interval = _options.CacheExpirationTime.TotalMilliseconds, AutoReset = true }; _timer.Elapsed += (s, e) => OnTimedElapsed(); if (!Directory.Exists(_options.DirectoryPath)) { Directory.CreateDirectory(_options.DirectoryPath); } }
/// <summary> /// Initializes a new channel factory. /// </summary> /// <param name="modifyChannelFactory"></param> /// <param name="modifyBinding"></param> protected virtual void Initialize(Action <ChannelFactory <T> > modifyChannelFactory = null, Action <System.ServiceModel.Channels.Binding> modifyBinding = null) { string cacheKey = string.Format("serviceproxy#channelfactory#{0}", typeof(T).Key()); ICachingOptions cachingOptions = new CachingOptions <ChannelFactory <T> > { EnableCaching = true, Expiration = new TimeSpan(24, 0, 0) }; ChannelFactory = CacheManager.GetOrAdd(cacheKey, () => GetChannelFactory(modifyChannelFactory, modifyBinding), cachingOptions); if (ChannelFactory.State == CommunicationState.Faulted) { ChannelFactory = GetChannelFactory(modifyChannelFactory, modifyBinding); CacheManager.Add(cacheKey, ChannelFactory, cachingOptions); } }
public async Task <ActionResult> UpdateCampaignAsync(int id, [FromBody] CampaignDTO campaignDto) { if (id < 1 || campaignDto is null) { return(BadRequest()); } Campaign campaignToUpdate = null; if (!_settings.CachingEnabled) { campaignToUpdate = await _context.Campaigns.FindAsync(id); } else { var options = new CachingOptions { StoreAs = StoreAs.SeperateEntities }; options.SetAbsoluteExpiration(DateTime.Now.AddMinutes(_settings.MarketingCacheExpirationTimeInMinutes)); campaignToUpdate = await _context.Campaigns.DeferredSingleOrDefault(c => c.Id == id).FromCacheAsync(options); } if (campaignToUpdate is null) { return(NotFound()); } campaignToUpdate.Name = campaignDto.Name; campaignToUpdate.Description = campaignDto.Description; campaignToUpdate.From = campaignDto.From; campaignToUpdate.To = campaignDto.To; campaignToUpdate.PictureUri = campaignDto.PictureUri; await _context.SaveChangesAsync(); if (_settings.CachingEnabled) { var cache = _context.GetCache(); var options = new CachingOptions(); options.SetAbsoluteExpiration(DateTime.Now.AddMinutes(_settings.MarketingCacheExpirationTimeInMinutes)); await Task.Run(() => cache.Insert(campaignToUpdate, out string cacheKey, options)); } return(CreatedAtAction(nameof(GetCampaignByIdAsync), new { id = campaignToUpdate.Id }, null)); }
public async Task <ActionResult <PaginatedItemsViewModel <CatalogItem> > > ItemsWithNameAsync(string name, [FromQuery] int pageSize = 10, [FromQuery] int pageIndex = 0) { long totalItems = -1L; List <CatalogItem> itemsOnPage = new List <CatalogItem>(); if (!_settings.EFCoreCachingEnabled) { totalItems = await _catalogContext.CatalogItems .Where(c => c.Name.StartsWith(name)) .LongCountAsync(); itemsOnPage = await _catalogContext.CatalogItems .Where(c => c.Name.StartsWith(name)) .Skip(pageSize * pageIndex) .Take(pageSize) .ToListAsync(); } else { var options = new CachingOptions { }; options.SetAbsoluteExpiration(DateTime.Now.AddMinutes(_settings.NCacheAbsoluteExpirationTime)); totalItems = await _catalogContext.CatalogItems .Where(c => c.Name.StartsWith(name)) .DeferredLongCount() .FromCacheAsync(options); // options.QueryIdentifier = $"ItemsWithNameAsync-{name}-{pageSize}-{pageIndex}"; options.StoreAs = StoreAs.SeperateEntities; itemsOnPage = (await _catalogContext.CatalogItems .Where(c => c.Name.StartsWith(name)) .Skip(pageSize * pageIndex) .Take(pageSize) .FromCacheAsync(options)) .ToList(); } itemsOnPage = ChangeUriPlaceholder(itemsOnPage); return(new PaginatedItemsViewModel <CatalogItem>(pageIndex, pageSize, totalItems, itemsOnPage)); }
private static void CreateMocks(CachingOptions caching) { for (var i = 0; i < Program.iterations; i++) { var rock = Rock.Create <IService>( options: new RockOptions(caching: caching)); rock.Handle(_ => _.Use()); var chunk = rock.Make(); chunk.Use(); rock.Verify(); if (i % 1000 == 0) { Console.Out.WriteLine(i); } } }
public RedisPlatformMemoryCache(IMemoryCache memoryCache , IConnectionMultiplexer connection , ISubscriber bus , IOptions <CachingOptions> cachingOptions , IOptions <RedisCachingOptions> redisCachingOptions , ILogger <RedisPlatformMemoryCache> log ) : base(memoryCache, cachingOptions, log) { _connection = connection; _log = log; _bus = bus; _cachingOptions = cachingOptions.Value; _redisCachingOptions = redisCachingOptions.Value; CancellableCacheRegion.OnTokenCancelled = CacheCancellableTokensRegistry_OnTokenCancelled; }
public async Task <PatchbotGame> GetAsync(string name, CancellationToken cancellationToken = default) { string trimmedName = name.Trim(); string lowercaseName = trimmedName.ToLowerInvariant(); await _lock.WaitAsync(cancellationToken).ConfigureAwait(false); try { PatchbotGame result; CachingOptions cachingOptions = _cachingOptions.Get(CacheOptionName); if (cachingOptions.Enabled) { result = _patchbotGameCache.Find(e => e.Entity.MatchesName(trimmedName)).FirstOrDefault(); if (result != null) { _log.LogTrace("Patchbot game {Game} found in cache", trimmedName); return(result); } } // get from DB _log.LogTrace("Retrieving patchbot game {Game} from database", trimmedName); FilterDefinition <PatchbotGame> filter = Builders <PatchbotGame> .Filter.Or( Builders <PatchbotGame> .Filter.Regex(dbData => dbData.Name, new BsonRegularExpression($"/^{trimmedName}$/i")), Builders <PatchbotGame> .Filter.AnyEq(dbData => dbData.Aliases, lowercaseName)); result = await _collection.Find(filter).FirstOrDefaultAsync(cancellationToken).ConfigureAwait(false); // if not found, return null if (result == null) { _log.LogTrace("Patchbot game {Game} not found", trimmedName); return(null); } _patchbotGameCache.AddOrReplace(result.Name, result, cachingOptions.Lifetime); return(result); } finally { _lock.Release(); } }
// GET: /<controller>/ public async Task <ActionResult> GetImageAsync(int catalogItemId) { if (catalogItemId <= 0) { return(BadRequest()); } CatalogItem item = null; if (!_settings.EFCoreCachingEnabled) { item = await _catalogContext.CatalogItems .SingleOrDefaultAsync(ci => ci.Id == catalogItemId); } else { var options = new CachingOptions { // QueryIdentifier = $"ItemByIdAsync-{catalogItemId}" }; options.SetAbsoluteExpiration(DateTime.Now.AddMinutes(_settings.NCacheAbsoluteExpirationTime)); item = await _catalogContext.CatalogItems.DeferredSingleOrDefault(ci => ci.Id == catalogItemId).FromCacheAsync(options); } if (item != null) { var webRoot = _env.WebRootPath; var path = Path.Combine(webRoot, item.PictureFileName); string imageFileExtension = Path.GetExtension(item.PictureFileName); string mimetype = GetImageMimeTypeFromImageFileExtension(imageFileExtension); var buffer = System.IO.File.ReadAllBytes(path); return(File(buffer, mimetype)); } return(NotFound()); }
public async Task <ActionResult> DeleteLocationByIdAsync(int campaignId, int userLocationRuleId) { if (campaignId < 1 || userLocationRuleId < 1) { return(BadRequest()); } UserLocationRule locationToDelete = null; if (!_settings.CachingEnabled) { locationToDelete = _context.Rules .OfType <UserLocationRule>() .SingleOrDefault(c => c.CampaignId == campaignId && c.Id == userLocationRuleId); } else { var options = new CachingOptions(); options.SetAbsoluteExpiration(DateTime.Now.AddMinutes(_settings.MarketingCacheExpirationTimeInMinutes)); locationToDelete = await _context.Rules .OfType <UserLocationRule>() .DeferredSingleOrDefault(c => c.CampaignId == campaignId && c.Id == userLocationRuleId) .FromCacheAsync(options); } if (locationToDelete is null) { return(NotFound()); } _context.Rules.Remove(locationToDelete); await _context.SaveChangesAsync(); if (_settings.CachingEnabled) { var cache = _context.GetCache(); await Task.Run(() => cache.Remove(locationToDelete)); } return(NoContent()); }
public RabbitMqAdapterFactory( string providerName, RabbitMqOptions rmqOptions, CachingOptions cachingOptions, IServiceProvider serviceProvider, ILoggerFactory loggerFactory) { if (string.IsNullOrEmpty(providerName)) { throw new ArgumentNullException(nameof(providerName)); } if (rmqOptions == null) { throw new ArgumentNullException(nameof(rmqOptions)); } if (cachingOptions == null) { throw new ArgumentNullException(nameof(cachingOptions)); } if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } _cache = new SimpleQueueAdapterCache(new SimpleQueueCacheOptions { CacheSize = cachingOptions.CacheSize }, providerName, loggerFactory); _mapper = new HashRingBasedStreamQueueMapper(new HashRingStreamQueueMapperOptions { TotalQueueCount = rmqOptions.NumberOfQueues }, rmqOptions.QueueNamePrefix); _failureHandler = Task.FromResult <IStreamFailureHandler>(new NoOpStreamDeliveryFailureHandler(false)); var serializer = typeof(TSerializer) == typeof(DefaultBatchContainerSerializer) ? new DefaultBatchContainerSerializer(serviceProvider.GetRequiredService <SerializationManager>()) : (IBatchContainerSerializer) new TSerializer(); _adapter = new RabbitMqAdapter(rmqOptions, cachingOptions, serializer, _mapper, providerName, loggerFactory); }
public async Task <ActionResult <List <CatalogBrand> > > CatalogBrandsAsync() { if (!_settings.EFCoreCachingEnabled) { return(await _catalogContext.CatalogBrands.ToListAsync()); } else { var options = new CachingOptions { StoreAs = StoreAs.SeperateEntities }; options.SetAbsoluteExpiration(DateTime.Now.AddMinutes(_settings.NCacheAbsoluteExpirationTime)); var result = await _catalogContext.CatalogBrands.FromCacheAsync(options); return(result.ToList()); } }