public IList <IApplicationModel> GetAll(string applicationName)
        {
            try
            {
                var storeData = new List <IApplicationModel>();
                var endpoints = RedisMultiplexer.GetEndPoints();
                var results   = new List <string>();
                foreach (var endpoint in endpoints)
                {
                    var server = RedisMultiplexer.GetServer(endpoint);
                    results.AddRange(server.Keys(pattern: $"{applicationName}:*").Select(key => Database.StringGet(key)).Select(dummy => (string)dummy));
                }
                if (results.Any())
                {
                    var json = $"[{results?.Aggregate((prev, next) => $"{prev}, {next}")}]";
                    return(JsonConvert.DeserializeObject <IList <IApplicationModel> >(json, JsonConfiguration.Settings));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(new List <IApplicationModel>());
        }
        public void RedisCache_Null_Logger_Throws_ArgumentNullException()
        {
            var multiplexer = new RedisMultiplexer <RedisCacheOptions>(new RedisCacheOptions {
                RedisConnectionString = ConfigurationUtils.GetConfiguration()["Redis:ConnectionString"]
            });

            Assert.Throws <ArgumentNullException>(() => new RedisCache <string>(multiplexer, null));
        }
예제 #3
0
 public RedisCache(RedisMultiplexer <RedisCacheOptions> multiplexer, ILogger <RedisCache <T> > logger)
 {
     if (multiplexer is null)
     {
         throw new ArgumentNullException(nameof(multiplexer));
     }
     this.options  = multiplexer.RedisOptions;
     this.database = multiplexer.Database;
     this.logger   = logger ?? throw new ArgumentNullException(nameof(logger));
 }
        public RedisCacheTests()
        {
            var logger  = new Mock <ILogger <RedisCache <string> > >();
            var options = new RedisCacheOptions {
                RedisConnectionString = ConfigurationUtils.GetConfiguration()["Redis:ConnectionString"]
            };
            var multiplexer = new RedisMultiplexer <RedisCacheOptions>(options);

            _cache = new RedisCache <string>(multiplexer, logger.Object);
        }
 public ClientStore(RedisMultiplexer <RedisConfigurationStoreOptions> multiplexer, ILogger <PersistedGrantStore> logger, ISystemClock clock)
 {
     if (multiplexer is null)
     {
         throw new ArgumentNullException(nameof(multiplexer));
     }
     options     = multiplexer.RedisOptions;
     database    = multiplexer.Database;
     this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
     this.clock  = clock;
 }
 public PersistedGrantStore(RedisMultiplexer <RedisOperationalStoreOptions> multiplexer, ILogger <PersistedGrantStore> logger, ISystemClock clock)
 {
     if (multiplexer is null)
     {
         throw new ArgumentNullException(nameof(multiplexer));
     }
     _options  = multiplexer.RedisOptions;
     _database = multiplexer.Database;
     _logger   = logger ?? throw new ArgumentNullException(nameof(logger));
     _clock    = clock;
 }
예제 #7
0
 public ResourceStore(RedisMultiplexer <RedisConfigurationStoreOptions> multiplexer, ILogger <PersistedGrantStore> logger, ISystemClock clock)
 {
     if (multiplexer is null)
     {
         throw new ArgumentNullException(nameof(multiplexer));
     }
     options     = multiplexer.RedisOptions;
     database    = multiplexer.Database;
     server      = database.Multiplexer.GetServer(multiplexer.Database.IdentifyEndpoint());
     this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
     this.clock  = clock;
 }
        public PersistedGrantStoreTests()
        {
            _logger = new Mock <ILogger <PersistedGrantStore> >();
            _clock  = new Mock <ISystemClock>();
            string connectionString = ConfigurationUtils.GetConfiguration()["Redis:ConnectionString"];
            var    options          = new RedisOperationalStoreOptions {
                RedisConnectionString = connectionString
            };

            _multiplexer = new RedisMultiplexer <RedisOperationalStoreOptions>(options);

            _store = new PersistedGrantStore(_multiplexer, _logger.Object, _clock.Object);
        }
예제 #9
0
 public void Setup()
 {
     database = new Mock <IDatabase>();
     server   = new Mock <IServer>();
     connectionMultiplexer = new Mock <IConnectionMultiplexer>();
     connectionMultiplexer.Setup(item => item.GetServer(It.IsAny <EndPoint>(), null)).Returns(server.Object);
     server.Setup(item => item.Multiplexer).Returns(connectionMultiplexer.Object);
     connectionMultiplexer.Setup(item => item.GetDatabase(-1, null)).Returns(database.Object);
     multiplexerFactory = options => Task.FromResult(connectionMultiplexer.Object);
     option             = new RedisConfiguration("Test");
     option.Endpoints   = new[] { new RedisEndpoint {
                                      Host = "localhost", Port = 7000
                                  } };
     multiplexer = new RedisMultiplexer(new NullLogger <RedisMultiplexer>(), option, multiplexerFactory);
 }
 public RedisApplication(string connection)
 {
     RedisMultiplexer = ConnectionMultiplexer.Connect(connection);
     Database         = RedisMultiplexer.GetDatabase();
 }
예제 #11
0
 /// <summary>
 /// RedisCache
 /// </summary>
 public RedisCacheContext(IOptions <RedisOptions> options)
 {
     RedisMultiplexer = ConnectionMultiplexer.Connect(options.Value.ConnectionString);
     RedisDatabase    = RedisMultiplexer.GetDatabase(options.Value.DataBaseIndex);
 }