Migrating from StackExchangeRedisCacheClient to RedisCacheClient
Asked Answered
S

1

8

I am building a project based on StackExchangeRedisCacheClient and obsolete has popped out: 'StackExchangeRedisCacheClient' is obsolete: 'This interface will be removed with the next major. Please use RedisCacheClient instead.'

so i'm trying to move from StackExchangeRedisCacheClient to RedisCacheClient unfortunately there is no documentation or some helpful info for doing that.

how do i create a cache client? with RedisCacheClient ? the require args are 'RedisCacheClient(IRedisCacheConnectionPoolManager, ISerializer, RedisConfiguration)'

i have looked at the following link and tried to implement a Single pool with no success https://github.com/imperugo/StackExchange.Redis.Extensions/issues/176# couldn't create a cacheClient after providing the connection string.

StackExchangeRedisCacheClient:(works fine)

  public CacheManager()
    {
        string connectionString = "localhost:300....."
        var serializer = new NewtonsoftSerializer();
        cacheClient = new StackExchangeRedisCacheClient(serializer, connectionString);
        clientName = cacheClient.Database.Multiplexer.ClientName;

    }

RedisCacheClient:

  public CacheManager()
    {
        string connectionString = "localhost:300....."
        var serializer = new NewtonsoftSerializer();
        cacheClient = new RedisCacheClient( *** ??? *** );
        clientName = cacheClient.Database.Multiplexer.ClientName;

    }
Somebody answered 1/9, 2019 at 15:6 Comment(2)
Do you found any other solution for this?Grandiloquent
im also looking for best solution.. anyone?Dufy
T
1

As per https://github.com/imperugo/StackExchange.Redis.Extensions/issues/176 if you don't care about having multiple connections you can use the following class:

internal class SinglePool : IRedisCacheConnectionPoolManager
    {
        private readonly IConnectionMultiplexer connection;

        public SinglePool(string connectionString)
        {
            this.connection = ConnectionMultiplexer.Connect(connectionString);
        }

        public IConnectionMultiplexer GetConnection()
        {
            return connection;
        }
    }
Trauma answered 12/12, 2019 at 13:12 Comment(1)
what if i care about mutiple connection ? how to use static?Dufy

© 2022 - 2024 — McMap. All rights reserved.