///
///Sorted Sets是将 Set 中的元素增加了一个权重参数 score,使得集合中的元素能够按 score 进行有序排列///1.带有权重的元素,比如一个游戏的用户得分排行榜///2.比较复杂的数据结构,一般用到的场景不算太多///
public classRedisZSetService : RedisBase
{#region 添加
///
///添加key/value,默认分数是从1.多*10的9次方以此递增的,自带自增效果///
public bool AddItemToSortedSet(string key, stringvalue)
{returnRedisBase.iClient.AddItemToSortedSet(key, value);
}///
///添加key/value,并设置value的分数///
public bool AddItemToSortedSet(string key, string value, doublescore)
{returnRedisBase.iClient.AddItemToSortedSet(key, value, score);
}///
///为key添加values集合,values集合中每个value的分数设置为score///
public bool AddRangeToSortedSet(string key, List values, doublescore)
{returnRedisBase.iClient.AddRangeToSortedSet(key, values, score);
}///
///为key添加values集合,values集合中每个value的分数设置为score///
public bool AddRangeToSortedSet(string key, List values, longscore)
{returnRedisBase.iClient.AddRangeToSortedSet(key, values, score);
}#endregion
#region 获取
///
///获取key的所有集合///
public List GetAll(stringkey)
{returnRedisBase.iClient.GetAllItemsFromSortedSet(key);
}///
///获取key的所有集合,倒叙输出///
public List GetAllDesc(stringkey)
{returnRedisBase.iClient.GetAllItemsFromSortedSetDesc(key);
}///
///获取集合,带分数///
public IDictionary GetAllWithScoresFromSortedSet(stringkey)
{returnRedisBase.iClient.GetAllWithScoresFromSortedSet(key);
}///
///获取key为value的下标值///
public long GetItemIndexInSortedSet(string key, stringvalue)
{returnRedisBase.iClient.GetItemIndexInSortedSet(key, value);
}///
///倒叙排列获取key为value的下标值///
public long GetItemIndexInSortedSetDesc(string key, stringvalue)
{returnRedisBase.iClient.GetItemIndexInSortedSetDesc(key, value);
}///
///获取key为value的分数///
public double GetItemScoreInSortedSet(string key, stringvalue)
{returnRedisBase.iClient.GetItemScoreInSortedSet(key, value);
}///
///获取key所有集合的数据总数///
public long GetSortedSetCount(stringkey)
{returnRedisBase.iClient.GetSortedSetCount(key);
}///
///key集合数据从分数为fromscore到分数为toscore的数据总数///
public long GetSortedSetCount(string key, double fromScore, doubletoScore)
{returnRedisBase.iClient.GetSortedSetCount(key, fromScore, toScore);
}///
///获取key集合从高分到低分排序数据,分数从fromscore到分数为toscore的数据///
public List GetRangeFromSortedSetByHighestScore(string key, double fromscore, doubletoscore)
{returnRedisBase.iClient.GetRangeFromSortedSetByHighestScore(key, fromscore, toscore);
}///
///获取key集合从低分到高分排序数据,分数从fromscore到分数为toscore的数据///
public List GetRangeFromSortedSetByLowestScore(string key, double fromscore, doubletoscore)
{returnRedisBase.iClient.GetRangeFromSortedSetByLowestScore(key, fromscore, toscore);
}///
///获取key集合从高分到低分排序数据,分数从fromscore到分数为toscore的数据,带分数///
public IDictionary GetRangeWithScoresFromSortedSetByHighestScore(string key, double fromscore, doubletoscore)
{returnRedisBase.iClient.GetRangeWithScoresFromSortedSetByHighestScore(key, fromscore, toscore);
}///
///获取key集合从低分到高分排序数据,分数从fromscore到分数为toscore的数据,带分数///
public IDictionary GetRangeWithScoresFromSortedSetByLowestScore(string key, double fromscore, doubletoscore)
{returnRedisBase.iClient.GetRangeWithScoresFromSortedSetByLowestScore(key, fromscore, toscore);
}///
///获取key集合数据,下标从fromRank到分数为toRank的数据///
public List GetRangeFromSortedSet(string key, int fromRank, inttoRank)
{returnRedisBase.iClient.GetRangeFromSortedSet(key, fromRank, toRank);
}///
///获取key集合倒叙排列数据,下标从fromRank到分数为toRank的数据///
public List GetRangeFromSortedSetDesc(string key, int fromRank, inttoRank)
{returnRedisBase.iClient.GetRangeFromSortedSetDesc(key, fromRank, toRank);
}///
///获取key集合数据,下标从fromRank到分数为toRank的数据,带分数///
public IDictionary GetRangeWithScoresFromSortedSet(string key, int fromRank, inttoRank)
{returnRedisBase.iClient.GetRangeWithScoresFromSortedSet(key, fromRank, toRank);
}///
///获取key集合倒叙排列数据,下标从fromRank到分数为toRank的数据,带分数///
public IDictionary GetRangeWithScoresFromSortedSetDesc(string key, int fromRank, inttoRank)
{returnRedisBase.iClient.GetRangeWithScoresFromSortedSetDesc(key, fromRank, toRank);
}#endregion
#region 删除
///
///删除key为value的数据///
public bool RemoveItemFromSortedSet(string key, stringvalue)
{returnRedisBase.iClient.RemoveItemFromSortedSet(key, value);
}///
///删除下标从minRank到maxRank的key集合数据///
public long RemoveRangeFromSortedSet(string key, int minRank, intmaxRank)
{returnRedisBase.iClient.RemoveRangeFromSortedSet(key, minRank, maxRank);
}///
///删除分数从fromscore到toscore的key集合数据///
public long RemoveRangeFromSortedSetByScore(string key, double fromscore, doubletoscore)
{returnRedisBase.iClient.RemoveRangeFromSortedSetByScore(key, fromscore, toscore);
}///
///删除key集合中分数最大的数据///
public string PopItemWithHighestScoreFromSortedSet(stringkey)
{returnRedisBase.iClient.PopItemWithHighestScoreFromSortedSet(key);
}///
///删除key集合中分数最小的数据///
public string PopItemWithLowestScoreFromSortedSet(stringkey)
{returnRedisBase.iClient.PopItemWithLowestScoreFromSortedSet(key);
}#endregion
#region 其它
///
///判断key集合中是否存在value数据///
public bool SortedSetContainsItem(string key, stringvalue)
{returnRedisBase.iClient.SortedSetContainsItem(key, value);
}///
///为key集合值为value的数据,分数加scoreby,返回相加后的分数///
public double IncrementItemInSortedSet(string key, string value, doublescoreBy)
{returnRedisBase.iClient.IncrementItemInSortedSet(key, value, scoreBy);
}///
///获取keys多个集合的交集,并把交集添加的newkey集合中,返回交集数据的总数///
public long StoreIntersectFromSortedSets(string newkey, string[] keys)
{returnRedisBase.iClient.StoreIntersectFromSortedSets(newkey, keys);
}///
///获取keys多个集合的并集,并把并集数据添加到newkey集合中,返回并集数据的总数///
public long StoreUnionFromSortedSets(string newkey, string[] keys)
{returnRedisBase.iClient.StoreUnionFromSortedSets(newkey, keys);
}#endregion}