public static void Bind(this IConfiguration config, RedisDbJsonConfig redisDbBinaryConfig) { var redisDbProviderConfig = config.GetSection("redisDbJsonProvider"); redisDbBinaryConfig.ConnectionString = ParseString(redisDbProviderConfig, "connectionString"); redisDbBinaryConfig.DatabaseId = ParseUInt16(redisDbProviderConfig, "databaseId"); }
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); }