public static ServerSetup UseRedisStorage(this ServerSetup setup, string connectionString, RedisStorageOptions options = null) { if (setup == null) { throw new ArgumentNullException(nameof(setup)); } if (string.IsNullOrEmpty(connectionString)) { throw new ArgumentNullException(nameof(connectionString)); } var redisOptions = ConfigurationOptions.Parse(connectionString); options = options ?? new RedisStorageOptions { Db = redisOptions.DefaultDatabase ?? 0 }; var connectionMultiplexer = ConnectionMultiplexer.Connect(connectionString); var storage = new RedisStorage(connectionMultiplexer, options); setup.Register <IStorage>(storage); return(setup); }
/// <summary> /// Set the options that are used for the Server /// </summary> /// <param name="setup"></param> /// <param name="options"></param> /// <returns></returns> public static ServerSetup UseOptions(this ServerSetup setup, Options options) { var def = setup.Resolve <Options>(); if (def == null) { setup.Register(options); def = options; } def.Merge(options); return(setup); }
public static ServerSetup UseRedisStorage(this ServerSetup setup, ConnectionMultiplexer connectionMultiplexer, RedisStorageOptions options = null) { if (setup == null) { throw new ArgumentNullException(nameof(setup)); } if (connectionMultiplexer == null) { throw new ArgumentNullException(nameof(connectionMultiplexer)); } var storage = new RedisStorage(connectionMultiplexer, options); setup.Register <IStorage>(storage); return(setup); }