Exemple #1
1
 public static ICacheAside CreatePubSubDoubleCache(IConnectionMultiplexer redisConnection, IItemSerializer itemSerializer, TimeSpan? defaultTtl = null)
 {
     var remoteCache = new RedisCache(redisConnection.GetDatabase(), itemSerializer, defaultTtl);
     return new DoubleCache(
       new SubscribingCache(new LocalCache.MemCache(defaultTtl), new RedisSubscriber(redisConnection, remoteCache, itemSerializer)),
       new PublishingCache(remoteCache, new RedisPublisher(redisConnection, itemSerializer)));
 }
        public RedisCacheStore()
        {
            var connectionSettings = RedisCacheConfiguration.Instance.Connection;

            var configurationOptions = new ConfigurationOptions
            {
                EndPoints = { { connectionSettings.Host, connectionSettings.Port } },
                ConnectTimeout = connectionSettings.ConnectionTimeoutInMilliseconds,
                Password = connectionSettings.AccessKey,
                Ssl = connectionSettings.Ssl,
                SyncTimeout = connectionSettings.OperationTimeoutInMilliseconds

            };

            _connection = ConnectionMultiplexer.Connect(configurationOptions);
        }
 public RedisSubscriber(IConnectionMultiplexer connection, ICacheAside remoteCache, IItemSerializer itemSerializer)
 {
     connection.GetSubscriber().Subscribe("cacheUpdate", CacheUpdated);
     _remoteCache = remoteCache;
     _itemSerializer = itemSerializer;
     _clientName = connection.ClientName;
     _knownTypes = new ConcurrentDictionary<string, Type>();
 }
        public RedisTestFixture()
        {
            if (!Debugger.IsAttached)
            {
                throw new NotImplementedException();
            }

            this.Connection = ConnectionMultiplexer.Connect(RedisConnectionString);
        }
        public RedisSubscriberTests()
        {
            _subscriber = A.Fake<ISubscriber>();
            _remoteCache = A.Fake<ICacheAside>();
            _itemSerializer = A.Fake<IItemSerializer>();

            _connection = A.Fake<IConnectionMultiplexer>();
            A.CallTo(() => _connection.GetSubscriber(A<object>._)).Returns(_subscriber);
        }
        public async Task<IRedis> GetDatabaseAsync(int databaseId)
        {
            _connectionMultiplexer = await ConnectionMultiplexer.ConnectAsync(new ConfigurationOptions
            {
                EndPoints = { ConnectionString},
                ConnectTimeout = (int)Timeout.TotalMilliseconds
            });

            var database = _connectionMultiplexer.GetDatabase(databaseId);

            return new Redis(database);
        }
 public RedisSyncCache(
     IConnectionMultiplexer connection,
     IJsonSerializer serializer,
     ILogger logger,
     string region,
     TimeSpan? ttl,
     TimeSpan? tti)
 {
     this.connection = connection;
     this.serializer = serializer;
     this.logger = logger;
     this.region = region;
     this.ttl = ttl;
     this.tti = tti;
 }
Exemple #8
0
        public void Open(RedisConfig config)
        {
            var connectionString = config.GetRedisConfiguration();
            var cancellationToken = new CancellationTokenSource(TimeSpan.FromSeconds(30)).Token;

            try
            {
                Task.Run(
                    () => _connection = ConnectionMultiplexer.Connect(ConfigurationOptions.Parse(connectionString)), cancellationToken).Wait(cancellationToken);
                _server = _connection.GetServer(config.Host, config.Port);
            }
            catch (Exception)
            {
                _connection = null;
            }
        }
Exemple #9
0
        public StackExchange.Redis.IDatabase GetDatabase()
        {

            if (_connectionMultiplexer == null)
            {
                lock (_locker)
                {
                    if (_connectionMultiplexer == null) // Double-checked locking
                    {
                        _connectionMultiplexer = ConnectionMultiplexer.Connect(_serverAddress);
                    }
                }
            }

            return _connectionMultiplexer.GetDatabase();
        }
 public RedisDatabaseWrapper(string ip, int database, string password = null, int port = 6379)
 {
     var options = new ConfigurationOptions
     {
         EndPoints =
         {
             new DnsEndPoint(ip, port)
         },
         KeepAlive = 180,
         Password = password,
         //DefaultVersion = new Version("2.8.5"),
         // Needed for cache clear
         AllowAdmin = true
     };
     this.database = database;
     _connectionMultiplexer = ConnectionMultiplexer.Connect(options);
 }
Exemple #11
0
 public RedisEvents(IConnectionMultiplexer redis)
 {
     Redis = redis;
 }
Exemple #12
0
 public RedisServerVsDb(IConnectionMultiplexer redis) 
 {
     Redis = redis;
 }
 public static IRedisConnection New(IConnectionMultiplexer mux)
 {
     return new ExistingRedisConnnection(mux);
 }
Exemple #14
0
 public static IServiceCollection AddMessagePipeRedis(this IServiceCollection services, IConnectionMultiplexer connectionMultiplexer, Action <MessagePipeRedisOptions> configure)
 {
     return(AddMessagePipeRedis(services, new SingleConnectionMultiplexerFactory(connectionMultiplexer), configure));
 }
 public RedisInstanceController(IConnectionMultiplexer multiplexConnection)
 {
     _RedisMUX = multiplexConnection;
 }
 public RequestThrottlingMiddleware(RequestDelegate next, IConnectionMultiplexer connection, int requestsPerMinuteThreshold)
 {
     this.next = next;
     this.connection = connection;
     this.requestsPerMinuteThreshold = requestsPerMinuteThreshold;
 }
 public RedisDatabaseController(IConnectionMultiplexer multiplexConnection)
 {
     _RedisMUX = multiplexConnection;
 }
 public void BaseSetup()
 {
     Configuration = new RedisConfiguration("localhost:6379");
     _multiplexer  = ConnectionMultiplexer.Connect($"{Configuration.ConnectionString},allowAdmin=true");
     Database      = _multiplexer.GetDatabase(Configuration.DatabaseId);
 }
Exemple #19
0
 public RedisProvider(string connectionString = null)
 {
     _connMultiplexer = RedisConnection.GetConnectionMultiplexer(connectionString);
 }
Exemple #20
0
 public RedisManager(string connection)
 {
     Multiplexer = ConnectionMultiplexer.Connect(connection);
     Database    = Multiplexer.GetDatabase();
 }
Exemple #21
0
 public RedisHelper(IConnectionMultiplexer conn, int db, IDataSerializer serializeProvider)
 {
     this._conn       = conn;
     this._database   = this._conn.SelectDatabase(db);
     this._serializer = serializeProvider;
 }
Exemple #22
0
 public RedisContext(IConnectionMultiplexer redis)
 {
     _redis = redis;
 }
Exemple #23
0
 public CacheManager(IConnectionMultiplexer redis)
 {
     this.redis = redis;
 }
 public BaseRepository(IConnectionMultiplexer redis, string nameSpace)
 {
     _redisConnection = redis;
     _namespace       = nameSpace;
 }
 public RedisSortedSetMap(string mapName, IConnectionMultiplexer connectionMultiplexer, ISerializer <TItem> serializer, int db = 0, CommandFlags readFlags = CommandFlags.None, CommandFlags writeFlags = CommandFlags.None)
     : base(mapName, connectionMultiplexer, db, readFlags, writeFlags)
 {
     _serializer = serializer;
 }
Exemple #26
0
 public RedisCommandBus(IConnectionMultiplexer connectionMultiplexer)
 {
     _connectionMultiplexer = connectionMultiplexer;
 }
            public InternalSortedSetList(TKey key, string listName, ISerializer <TItem> serializer, IConnectionMultiplexer connectionMultiplexer, int db, CommandFlags readFlags, CommandFlags writeFlags, ITransaction transaction = null)
                : base(listName, serializer, connectionMultiplexer, db, readFlags, writeFlags)
            {
                if (key == null)
                {
                    throw new ArgumentNullException(nameof(key));
                }
                Key = key;

                _transaction = transaction;
            }
 public RedisCandlesCacheService(IConnectionMultiplexer multiplexer, MarketType market)
 {
     _multiplexer   = multiplexer;
     _market        = market;
     _activeSlotKey = GetActiveSlotKey(_market);
 }
Exemple #29
0
 public ResponseCacheService(IConnectionMultiplexer redis)
 {
     _database = redis.GetDatabase();
 }
 public async Task Init(CancellationToken ct)
 {
     _connectionMultiplexer = await _connectionMultiplexerFactory.CreateAsync(_options.ConnectionString);
 }
Exemple #31
0
 public static IServiceCollection AddMessagePipeRedis(this IServiceCollection services, IConnectionMultiplexer connectionMultiplexer)
 {
     return(AddMessagePipeRedis(services, new SingleConnectionMultiplexerFactory(connectionMultiplexer), _ => { }));
 }
 public RedisCacheRateLimitCounterStore(IConnectionMultiplexer redis)
 {
     _redis = redis ?? throw new ArgumentNullException(nameof(redis));
 }
Exemple #33
0
 public RedisHelper(string connectionString)
 {
     this.ConnectionString = connectionString;
     _connection           = ConnectionMultiplexer.Connect(ConnectionString);
     _db = GetDatabase();
 }
 public HomeController(IDistributedCache cache, IConnectionMultiplexer conn)
 {
     _cache = cache;
     _conn  = conn;
 }
 public MockRedisTarget(IConnectionMultiplexer connectionMultiplexer)
 {
     _connectionMultiplexer = connectionMultiplexer;
 }
 public RedisCacheService(IConnectionMultiplexer connection)
 {
     _instance = connection.GetDatabase();
 }
 public ExistingRedisConnnection(IConnectionMultiplexer mux)
 {
     multiplexer = mux;
 }
 public RedisCacheService(IConnectionMultiplexer connectionMultiplexer)
 {
     _connectionMultiplexer = connectionMultiplexer;
 }
 static bool IsConnected(IConnectionMultiplexer connectionMultiplexer)
 {
     return connectionMultiplexer != null && connectionMultiplexer.IsConnected;
 }
 public RequestThrottlingMiddleware(RequestDelegate next, IConnectionMultiplexer connection, int requestsPerMinuteThreshold)
 {
     this.next       = next;
     this.connection = connection;
     this.requestsPerMinuteThreshold = requestsPerMinuteThreshold;
 }
 public RedisPipelinesAndMux(IConnectionMultiplexer redis)
 {
     Db = redis.GetDatabase();
     Sub = redis.GetSubscriber();
 }
Exemple #42
0
 public RedisPublisher(IConnectionMultiplexer connection, IItemSerializer itemSerializer)
 {
     _connection = connection;
     _itemSerializer = itemSerializer;
 }
Exemple #43
0
 public RedisTests()
 {
     _multiplexer = ConnectionMultiplexer.Connect("localhost");
     _serializer = new JsonRedisValueSerializer();
     _cache = new RedisCache(_multiplexer, _serializer);
 }
Exemple #44
0
 public RedisProfiling(IConnectionMultiplexer redis)
 {
     Redis = redis;
 }
 public RedisRepository(IConnectionMultiplexer redis)
 {
     _redis = redis;
 }
Exemple #46
0
 public RedisHealthCheck(IConnectionMultiplexer connectionMultiplexer)
 {
     this.connectionMultiplexer = connectionMultiplexer;
 }
Exemple #47
0
            public InternalSet(TKey key, string setName, ISerializer <TItem> serializer, IConnectionMultiplexer connectionMultiplexer, int db, CommandFlags readFlags, CommandFlags writeFlags, ITransaction transaction = null, bool useScanOnEnumeration = true)
                : base(setName, connectionMultiplexer, serializer, db, readFlags, writeFlags, useScanOnEnumeration)
            {
                if (key == null)
                {
                    throw new ArgumentNullException(nameof(key));
                }
                Key = key;

                _transaction = transaction;
            }
 public DeletedStateHandler(RedisStorageOptions options, IConnectionMultiplexer multiplexer) : base(options, multiplexer)
 {
 }
Exemple #49
0
        private static async Task SyncDatabase(IServer redisServer, int database, IConnectionMultiplexer srcRedis, IConnectionMultiplexer destRedis)
        {
            Console.WriteLine($"-- sync db:{database} begin --");

            var pageSize  = batchSize;
            var pageIndex = 0;

            while (pageSize >= batchSize)
            {
                pageSize = 0;
                foreach (var redisKey in redisServer.Keys(database, pageSize: batchSize, pageOffset: pageIndex))
                {
                    Console.WriteLine($"-- sync db:{database},{redisKey} begin --");
                    try
                    {
                        await SyncRedisKeyAsync(srcRedis.GetDatabase(database), redisKey, destRedis.GetDatabase(database));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine($"sync exception:{e}");
                    }
                    Console.WriteLine($"-- sync db:{database},{redisKey} end --");

                    pageSize++;
                }
                pageIndex++;
            }

            Console.WriteLine($"-- sync db:{database} end --");
        }
 public RedisListener(ILogger <RedisListener> logger, IConnectionMultiplexer multiplexer)
 {
     _logger      = logger;
     _multiplexer = multiplexer;
 }
 public RedisTransactions(IConnectionMultiplexer redis)
 {
     Db = redis.GetDatabase();
 }
 public RedisConfiuguration(IConnectionMultiplexer redis)
 {
     Redis = redis;
 }
Exemple #53
0
 public RedisPubSub(IConnectionMultiplexer redis)
 {
     Redis = redis;
 }
 public RedisClient(IConnectionMultiplexer multiplexer, int database)
 {
     _multiplexer = multiplexer;
     _database = database;
 }
Exemple #55
0
 public LocationRepository(IConnectionMultiplexer redisConnection) : base(redisConnection, "location")
 {
 }
 public RedisClientController(IConnectionMultiplexer connectionMultiplexer)
 {
     _RedisMUX = connectionMultiplexer;
 }
Exemple #57
0
 public RedisBasicUsage(IConnectionMultiplexer redis)
 {
     Redis = redis;
 }
Exemple #58
0
 public BasketRepository(IConnectionMultiplexer redis)
 {
     _database = redis.GetDatabase();
 }
 public RedisKeyValueChannel(IConnectionMultiplexer redis)
 {
     Db = redis.GetDatabase();
 }
Exemple #60
0
 public RedisSubscriber(IConnectionMultiplexer connectionMultiplexer)
 {
     _connectionMultiplexer = connectionMultiplexer;
 }