Пример #1
0
        public static void Bind(this IConfiguration config, RedisDbJsonConfig redisDbBinaryConfig)
        {
            var redisDbProviderConfig = config.GetSection("redisDbJsonProvider");

            redisDbBinaryConfig.ConnectionString = ParseString(redisDbProviderConfig, "connectionString");
            redisDbBinaryConfig.DatabaseId       = ParseUInt16(redisDbProviderConfig, "databaseId");
        }
Пример #2
0
        public RedisDbJsonContext(RedisDbJsonConfig jsonConfig)
        {
            if (jsonConfig == null)
            {
                throw new ArgumentNullException(nameof(jsonConfig));
            }

            var host = string.IsNullOrEmpty(jsonConfig.ConnectionString) ? "localhost" : jsonConfig.ConnectionString;
            var dbId = jsonConfig.DatabaseId ?? 0;

            _connection = ConnectionMultiplexer.Connect(host);
            _redisDb    = _connection.GetDatabase(dbId);
        }