ServiceStack Redis v4.0.52 IRedisClient.Db setter 未按预期工作
ServiceStack Redis v4.0.52 IRedisClient.Db setter not working as expected
我们最近将项目中的 ServiceStack DLL 从版本 4.0.38 升级到版本 4.0.52。我们正在这样打电话:
var clientManager = new BasicRedisClientManager("127.0.0.1");
var client = clientManager.GetClient();
client.Db = 3; // set the DB to 3
var item = DateTime.Now.Ticks.ToString();
client.AddItemToList("test_q", item);
在版本 4.0.38 中,此调用正确地生成了 DB 3 (select 3
) 中 test_q
列表中的一个项目。但是,当我们升级到版本 4.0.52 时,将 DB 设置为 3 不再有效,并且该项目最终位于默认 DB 0 中。
这是错误还是 API 有变化?
这是行为上的改变,现已解决 in this commit which is due to GetClient()
now returning an already connected client. This change is available from v4.0.53 that's now available on MyGet。
强制对已连接的客户端进行数据库更改的一种方法是使用显式 ChangeDb()
API,例如:
((RedisClient)client).ChangeDb(3);
另一种选择是在连接字符串中指定 Db,例如:
var clientManager = new BasicRedisClientManager("127.0.0.1?db=3");
我们最近将项目中的 ServiceStack DLL 从版本 4.0.38 升级到版本 4.0.52。我们正在这样打电话:
var clientManager = new BasicRedisClientManager("127.0.0.1");
var client = clientManager.GetClient();
client.Db = 3; // set the DB to 3
var item = DateTime.Now.Ticks.ToString();
client.AddItemToList("test_q", item);
在版本 4.0.38 中,此调用正确地生成了 DB 3 (select 3
) 中 test_q
列表中的一个项目。但是,当我们升级到版本 4.0.52 时,将 DB 设置为 3 不再有效,并且该项目最终位于默认 DB 0 中。
这是错误还是 API 有变化?
这是行为上的改变,现已解决 in this commit which is due to GetClient()
now returning an already connected client. This change is available from v4.0.53 that's now available on MyGet。
强制对已连接的客户端进行数据库更改的一种方法是使用显式 ChangeDb()
API,例如:
((RedisClient)client).ChangeDb(3);
另一种选择是在连接字符串中指定 Db,例如:
var clientManager = new BasicRedisClientManager("127.0.0.1?db=3");