我正在建立一个基于 StackExchangeRedisCacheClientClient 的项目,并且已经过时了:
'StackExchangeRedisCacheCacheClient'已过时:'此接口(interface)将在下一个主要版本中删除。请改为使用RedisCacheClient。”
所以我想从 StackExchangeRedisCacheClient 移到 RedisCacheClient
不幸的是,目前尚无文档或一些有用的信息。
如何创建缓存客户端?与 RedisCacheClient 吗?必需参数为“RedisCacheClient( IRedisCacheConnectionPoolManager , ISerializer , RedisConfiguration )”
我查看了以下链接,并尝试实现没有成功的单个池https://github.com/imperugo/StackExchange.Redis.Extensions/issues/176#
提供连接字符串后无法创建cacheClient。
StackExchangeRedisCacheClient:(工作正常)
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;
}
最佳答案
根据https://github.com/imperugo/StackExchange.Redis.Extensions/issues/176,如果您不关心多个连接,则可以使用以下类:
internal class SinglePool : IRedisCacheConnectionPoolManager
{
private readonly IConnectionMultiplexer connection;
public SinglePool(string connectionString)
{
this.connection = ConnectionMultiplexer.Connect(connectionString);
}
public IConnectionMultiplexer GetConnection()
{
return connection;
}
}
关于c# - 从StackExchangeRedisCacheClient迁移到RedisCacheClient,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57747110/