Exemplo n.º 1
0
        public static void Bind(this IConfiguration config, RedisDbBinaryConfig redisDbBinaryConfig)
        {
            var redisDbProviderConfig = config.GetSection("redisDbBinaryProvider");

            redisDbBinaryConfig.ConnectionString = ParseString(redisDbProviderConfig, "connectionString");
            redisDbBinaryConfig.DatabaseId       = ParseUInt16(redisDbProviderConfig, "databaseId");
        }
Exemplo n.º 2
0
        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);
        }