/// <summary> /// Creates a scoped layered cache /// </summary> /// <param name="name"></param> /// <param name="level1">First cache to check (e.g. in-memory scoped cache)</param> /// <param name="level2">Fallback cache (e.g. distributed scoped cache)</param> public LayeredScopedCache(String name, IScopedCache level1, IScopedCache level2) { this.Name = name; if (level1 == null) { throw new ApplicationException("innerCache1 must not be null"); } if (level2 == null) { throw new ApplicationException("innerCache2 must not be null"); } if (level2 == level1) { throw new ApplicationException( string.Format("level2 must not be the same as level1, received {0}={1} and {2}={3}", "level1", level1.Name, "level2", level2.Name)); } this.level1 = level1; this.level2 = level2; this.policy = new LayeredScopedCachePolicy { Level1CacheName = level1.Name, Level2CacheName = level2.Name }; }
public ApplicationService( IBusControl publishEndpoint, IScopedCache scopedCache, ILogger <ApplicationService> logger) { this.publishEndpoint = publishEndpoint; this.scopedCache = scopedCache; this.logger = logger; }
public CustomerService( IDbContextFactory <TenantDbContext, int> tenantDbContextFactory, IScopedCache scopedCache, IMapper mapper) { _scopedCache = scopedCache; _mapper = mapper; _tenantDbContext = tenantDbContextFactory.Create(_scopedCache.TenantId); }
/// <summary> /// Creates a scoped layered cache /// </summary> /// <param name="name"></param> /// <param name="level1CacheName">Name of first cache to check (e.g. in-memory scoped cache), should be registered in CacheManager</param> /// <param name="level2CacheName">Name of fallback cache (e.g. distributed scoped cache), should be registered in CacheManager</param> public LayeredScopedCache(String name, String level1CacheName, String level2CacheName) { this.Name = name; var level1 = CacheManager.GetCache(level1CacheName); if (!(level1 is IScopedCache)) { var message = (level1 == null) ? $"Cache is not registered: level1CacheName={level1CacheName}" : $"Cache type does not implement {nameof(IScopedCache)}: level1CacheName={level1CacheName}"; throw new ApplicationException(message); } var level2 = CacheManager.GetCache(level2CacheName); if (!(level2 is IScopedCache)) { var message = (level2 == null) ? $"Cache is not registered: level2CacheName={level2CacheName}" : $"Cache type does not implement {nameof(IScopedCache)}: level2CacheName={level2CacheName}"; throw new ApplicationException(message); } if (level2 == level1) { throw new ApplicationException( string.Format( "level2 must not be the same as level1, received {0}={1}, {2}={3}, which map to {4} and {5}", "level1CacheName", level1CacheName, "level2CacheName", level2CacheName, level1.Name, level2.Name)); } this.level1 = (IScopedCache)level1; this.level2 = (IScopedCache)level2; this.policy = new LayeredScopedCachePolicy { Level1CacheName = level1.Name, Level2CacheName = level2.Name }; }
public ScopedCacheMiddleware(IScopedCache cache) { _cache = cache; }
public ScopedLoggerFilter(IScopedCache scopedCache) { this.scopedCache = scopedCache; }
public TestConsumer(IScopedCache scopedCache, ILogger <TestConsumer> logger) { this.logger = logger; this.scopedCache = scopedCache; }
public BookingService(BookingServiceContext context, IMapper mapper, IScopedCache cache) { _context = context; _mapper = mapper; _cache = cache; }