示例#1
0
        public async Task UpdateClientRuleCache(string clientid, string path)
        {
            var region = CzarCacheRegion.AuthenticationRegion;
            var key    = CzarOcelotHelper.ComputeCounterKey(region, clientid, "", path);

            key = CzarOcelotHelper.GetKey(_options.RedisOcelotKeyPrefix, region, key);
            var result = await _clientAuthenticationRepository.ClientAuthenticationAsync(clientid, path);

            var data = new ClientRoleModel()
            {
                CacheTime = DateTime.Now, Role = result
            };

            if (_options.ClusterEnvironment)
            {
                RedisHelper.Set(key, data);              //加入redis缓存
                RedisHelper.Publish(key, data.ToJson()); //发布事件
            }
            else
            {
                _cache.Remove(key);
            }
        }
示例#2
0
        public async Task UpdateClientReRouteWhiteListCache(string clientid, string path)
        {
            var region = CzarCacheRegion.ClientReRouteWhiteListRegion;
            var key    = clientid + path;

            key = CzarOcelotHelper.GetKey(_options.RedisOcelotKeyPrefix, region, key);
            var result = await _clientRateLimitRepository.CheckClientReRouteWhiteListAsync(clientid, path);

            var data = new ClientRoleModel()
            {
                CacheTime = DateTime.Now, Role = result
            };

            if (_options.ClusterEnvironment)
            {
                RedisHelper.Set(key, data);              //加入redis缓存
                RedisHelper.Publish(key, data.ToJson()); //发布事件
            }
            else
            {
                _cache.Remove(key);
            }
        }