我试图添加一个SortedSet项,且其密钥到期。有没有比2个电话更好的方法了? 这是我目前正在使用的:
private IDatabase GetDataBase()
{
return this.GetLeastBusyMultiplexer().GetDatabase();
}
private ConnectionMultiplexer GetLeastBusyMultiplexer()
{
var leastBusyMultiplexer = this.Multiplexers.Aggregate((min, next) =>
{
if (min == null || next.Value.GetCounters().TotalOutstanding < min.Value.GetCounters().TotalOutstanding)
{
return next;
}
return min;
});
return leastBusyMultiplexer.Value;
}`
在这里添加到数据库:
var RedisDatabase = GetDataBase();
RedisDatabase.SortedSetAddAsync(key, sortedSetEntry,whenNotExists)).ConfigureAwait(false);
RedisDatabase.KeyExpireAsync(key, ttlValue).ConfigureAwait(false);