Beispiel #1
0
        public async Task Invoke(HttpContext httpContext)
        {
            if (httpContext.Request.Method != "GET")
            {
                await _next.Invoke(httpContext);
            }
            else
            {
                ICustomMemoryCache memoryCache = httpContext.RequestServices.GetService <ICustomMemoryCache>();
                var key       = httpContext.Request.Path.Value;
                var pathSplit = key.Split("/");
                if (pathSplit.Length >= 4 && _addUserIdKeys.Contains(pathSplit[3].ToLower()))
                {
                    var userId = httpContext.User.Claims.GetUserId().Data;
                    key = userId + key;
                }

                if (memoryCache.TryGetValue(key, out var value))
                {
                    var logger = NLog.Web.NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
                    logger.Info("From Cache");
                    ResponseHandler(httpContext, value);
                }
                else
                {
                    await _next.Invoke(httpContext);
                }
            }
        }
 protected ControllerCoreBasicApi(ILogger <TClass> logger, ICustomMemoryCache cache, SchedulerContext scheduleContext)
 {
     this._logger        = logger;
     this._cache         = cache;
     this._cacheKey_all  = $"{typeof(TEntity)}_All";
     this._cacheKey_byId = $"{typeof(TEntity)}_byId:";
     this._context       = scheduleContext;
     this._query         = this._context.Set <TEntity>();
 }
        public RabbitHostedService(ILogger <RabbitHostedService> logger, IRabbitManager rabbitManager, IOptions <AppSettings> options,
                                   IHubContext <PanelDataHub> hubContext, ICustomMemoryCache customMemoryCache)
        {
            this.logger            = logger;
            this.rabbitManager     = rabbitManager;
            this.hubContext        = hubContext;
            this.customMemoryCache = customMemoryCache;
            rabbitConfig           = options.Value.RabbitConfig;

            jsonSerializerOptions = new JsonSerializerOptions()
            {
                PropertyNamingPolicy = JsonNamingPolicy.CamelCase
            };
        }
Beispiel #4
0
 public PackageService(
     [NotNull] NuGetListConfiguration deploymentConfiguration,
     [NotNull] ICustomMemoryCache memoryCache,
     [NotNull] IKeyValueConfiguration keyValueConfiguration,
     [NotNull] ILogger logger,
     [NotNull] CustomHttpClientFactory httpClientFactory)
 {
     _deploymentConfiguration = deploymentConfiguration ??
                                throw new ArgumentNullException(nameof(deploymentConfiguration));
     _memoryCache           = memoryCache ?? throw new ArgumentNullException(nameof(memoryCache));
     _keyValueConfiguration =
         keyValueConfiguration ?? throw new ArgumentNullException(nameof(keyValueConfiguration));
     _logger            = logger ?? throw new ArgumentNullException(nameof(logger));
     _httpClientFactory = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory));
 }
 public MonitoringService(
     [NotNull] ILogger logger,
     [NotNull] IHttpClientFactory httpClientFactory,
     [NotNull] IPackageService packageService,
     TimeoutHelper timeoutHelper,
     NuGetListConfiguration nuGetListConfiguration,
     IApplicationSettingsStore applicationSettingsStore,
     ICustomMemoryCache customMemoryCache)
 {
     _logger                   = logger ?? throw new ArgumentNullException(nameof(logger));
     _httpClientFactory        = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory));
     _packageService           = packageService ?? throw new ArgumentNullException(nameof(packageService));
     _timeoutHelper            = timeoutHelper;
     _nuGetListConfiguration   = nuGetListConfiguration;
     _applicationSettingsStore = applicationSettingsStore;
     _customMemoryCache        = customMemoryCache;
 }
        public ActionResult InvalidateCache([FromBody] InvalidateCache invalidateCache, [FromServices] ICustomMemoryCache customMemoryCache)
        {
            customMemoryCache.Invalidate(invalidateCache.Prefix);

            return(RedirectToAction(nameof(Index)));
        }
Beispiel #7
0
 public MartenSettingsStore(IDocumentStore documentStore, ICustomMemoryCache memoryCache)
 {
     _documentStore = documentStore;
     _memoryCache   = memoryCache;
 }
Beispiel #8
0
        public ActionResult InvalidateCache([FromServices] ICustomMemoryCache customMemoryCache)
        {
            customMemoryCache.Invalidate(Request.Query["prefix"]);

            return(RedirectToAction(nameof(Index)));
        }
 public AppointmentsController(ILogger <AppointmentsController> logger, ICustomMemoryCache cache, SchedulerContext context)
     : base(logger, cache, context)
 {
 }
 public PanelDataHub(ILogger <PanelDataHub> logger, ICustomMemoryCache customMemoryCache)
 {
     this.logger            = logger;
     this.customMemoryCache = customMemoryCache;
 }
Beispiel #11
0
 public EnvironmentTypeService(IDocumentStore martenStore, ICustomMemoryCache cache)
 {
     _store = martenStore;
     _cache = cache;
 }
 public static async Task <ImmutableArray <EnvironmentType> > GetEnvironmentTypes(this IDocumentStore documentStore,
                                                                                  ICustomMemoryCache memoryCache,
                                                                                  CancellationToken cancellationToken =
                                                                                  default)
 {
     if (memoryCache.TryGetValue(CacheKey, out EnvironmentType[]? environmentTypes))