Exemplo n.º 1
0
 private Task <bool> AddToIndex(RedisIndex index, string value, double indexScore)
 {
     return(this._redisDb.SortedSetAddAsync(index.ToString(), value, indexScore));
 }
Exemplo n.º 2
0
        public async Task <UInt256> GetFromHashIndex(RedisIndex index, double indexScore)
        {
            var values = (await _redisDb.SortedSetRangeByScoreAsync(index.ToString(), indexScore, indexScore)).ToStringArray();

            return(values.Any() ? UInt256.Parse(values.First()) : null);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Retrieves the length / number of elements in an index
 /// </summary>
 /// <param name="index">Index to retrieve the length of</param>
 /// <returns></returns>
 public long GetIndexLength(RedisIndex index)
 {
     return(_redisDb.SortedSetLength(index.ToString()));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Retrieves a specified range of values from a Redis Sorted Set based on a range of scores
 /// </summary>
 /// <param name="index">Index to search</param>
 /// <param name="startIndexScore">Range starting score</param>
 /// <param name="endIndexScore">Range end score</param>
 /// <returns></returns>
 public RedisValue[] GetRangeFromIndex(RedisIndex index, double startIndexScore, double endIndexScore)
 {
     return(_redisDb.SortedSetRangeByScore(index.ToString(), startIndexScore, endIndexScore));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Retrieves a specified value from a Redis Sorted Set based on score.
 /// </summary>
 /// <param name="index">Index to search</param>
 /// <param name="indexScore">Score to retrieve.</param>
 /// <returns></returns>
 public RedisValue[] GetFromIndex(RedisIndex index, double indexScore)
 {
     return(_redisDb.SortedSetRangeByScore(index.ToString(), indexScore, indexScore));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Adds a specified value and score to a Redis Sorted Set.  Using a Redis Sorted Set will give us a O(log(n)) complexity on search.
 /// </summary>
 /// <param name="index">Index to write</param>
 /// <param name="indexScore">Score to assign</param>
 /// <param name="value">Value associated with score</param>
 public void AddToIndex(RedisIndex index, double indexScore, string value)
 {
     _redisDb.SortedSetAdd(index.ToString(), value, indexScore);
 }