public static void Bind(this IConfiguration config, RedisDbBinaryConfig redisDbBinaryConfig) { var redisDbProviderConfig = config.GetSection("redisDbBinaryProvider"); redisDbBinaryConfig.ConnectionString = ParseString(redisDbProviderConfig, "connectionString"); redisDbBinaryConfig.DatabaseId = ParseUInt16(redisDbProviderConfig, "databaseId"); }
public RedisDbContext(RedisDbBinaryConfig binaryConfig) { if (binaryConfig == null) { throw new ArgumentNullException(nameof(binaryConfig)); } var host = string.IsNullOrEmpty(binaryConfig.ConnectionString) ? "localhost" : binaryConfig.ConnectionString; var dbId = binaryConfig.DatabaseId ?? 0; _connection = ConnectionMultiplexer.Connect(host); _redisDb = _connection.GetDatabase(dbId); }