コード例 #1
0
        /// <summary>
        /// Intercepts a method and after invocation checks to see if the request implements ICacheable
        /// if so, the ICacheItemInvalidator is invoked to remove the item from the cache
        /// </summary>
        public virtual void Intercept(IInvocation invocation)
        {
            ArgumentValidation.ComponentNotNull(_cacheInvalidator);

            invocation.Proceed();

            _cacheInvalidator.Invalidate(invocation.ReturnValue as ICacheInvalidation);
        }
コード例 #2
0
        public async Task <IHttpActionResult> Delete(string apiKey)
        {
            var tasks = new List <Task>()
            {
                _apiSettings.DeleteAsync(apiKey),
                _chaosConfigurationSettings.DeleteAsync(apiKey),
            };

            await Task.WhenAll(tasks);

            _cacheInvalidator.Invalidate(apiKey);

            return(new StatusCodeResult(HttpStatusCode.NoContent, Request));
        }
コード例 #3
0
        public async Task <IHttpActionResult> Post(UpdateConfigurationRequest updateConfiguration)
        {
            var apiKey = updateConfiguration.ApiKey;

            var hostForwardSettings = await _apiSettingsData.GetByApiKeyAsync(apiKey);

            if (hostForwardSettings == null)
            {
                return(BadRequest(Constants.InvalidApiKey));
            }

            var chaosConfiguration = UpdateRequestToConfigurationConverter.ToChaosConfiguration(updateConfiguration);

            if (!chaosConfiguration.IsValid())
            {
                return(BadRequest(chaosConfiguration.ValidationErrors.AsFormattingString()));
            }

            await _chaosConfigurationSettings.CreateOrUpdateAsync(hostForwardSettings, apiKey, chaosConfiguration);

            _cacheInvalidator.Invalidate(apiKey);

            return(Created(hostForwardSettings.ForwardApiHostName, chaosConfiguration));
        }
コード例 #4
0
        public CacheInvalidatorCallback(ICacheInvalidator cacheInvalidator)
        {
            _invalidator = cacheInvalidator;
            _callback = new GenericCallback((out int return_type, out jvalue return_value, IntPtr input) =>
            {
                try
                {
                    string key = (string)JavaClass.GetTypedInstance(typeof(string), jvalue.From(input).l);
                    _invalidator.Invalidate(key);

                    return_value = new jvalue();
                    return_type = 0;
                }
                catch (Exception exception)
                {
                    return_value = jvalue.CreateCBRetVal(exception);
                    return_type = 1;
                }

                return 0;
            });

            base.JObject = _constructor.construct(0, _callback);
        }