Ejemplo n.º 1
0
        public static RedisArray.Tuples <string, double> ZRevRangeByScoreWithScores(string key, double max, double min, bool exclusiveMax = false, bool exclusiveMin = false, long?offset = null, long?count = null)
        {
            string min_score = RedisArgs.GetScore(min, exclusiveMin);
            string max_score = RedisArgs.GetScore(max, exclusiveMax);

            return(ZRevRangeByScoreWithScores(key, max_score, min_score, offset, count));
        }
Ejemplo n.º 2
0
        public static RedisArray.Strings ZRangeByScore(string key, double min, double max, bool withScores = false, bool exclusiveMin = false, bool exclusiveMax = false, long?offset = null, long?count = null)
        {
            string min_score = RedisArgs.GetScore(min, exclusiveMin);
            string max_score = RedisArgs.GetScore(max, exclusiveMax);

            return(ZRangeByScore(key, min_score, max_score, withScores, offset, count));
        }
Ejemplo n.º 3
0
        public static RedisInt ZRemRangeByScore(string key, double min, double max, bool exclusiveMin = false, bool exclusiveMax = false)
        {
            string min_score = RedisArgs.GetScore(min, exclusiveMin);
            string max_score = RedisArgs.GetScore(max, exclusiveMax);

            return(new RedisInt("ZREMRANGEBYSCORE", key, min_score, max_score));
        }
Ejemplo n.º 4
0
        public static RedisInt ZCount(string key, double min, double max, bool exclusiveMin = false, bool exclusiveMax = false)
        {
            string min_score = RedisArgs.GetScore(min, exclusiveMin);
            string max_score = RedisArgs.GetScore(max, exclusiveMax);

            return(ZCount(key, min_score, max_score));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 返回有序集 <paramref name="key"/> 中,权重值在 <paramref name="min"/> 和 <paramref name="max"/> 之间的成员的数量。
        /// </summary>
        /// <param name="client">Redis 客户端。</param>
        /// <param name="key">有序集的键名。</param>
        /// <param name="min">权重最小值。<paramref name="min"/> 可以是 <see cref="System.Double.MinValue"/> -或- <see cref="System.Double.NegativeInfinity"/>,表示有序集的最小值。</param>
        /// <param name="max">权重最大值。<paramref name="max"/> 可以是 <see cref="System.Double.MaxValue"/> -或- <see cref="System.Double.PositiveInfinity"/>,表示有序集的最高值。</param>
        /// <param name="exclusiveMin">指示最小值是否为开区间(true 时表示不含最小值)。</param>
        /// <param name="exclusiveMax">指示最大值是否为开区间(true 时表示不含最大值)。</param>
        /// <returns>返回权重值包含指定区间的成员数量。</returns>
        public static long ZCount(this IRedisClient client, string key, double min, double max, bool exclusiveMin = false, bool exclusiveMax = false)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentNullException("key");
            }

            return(client.Execute(new RedisInteger("ZCOUNT", key
                                                   , RedisArgs.GetScore(min, exclusiveMin)
                                                   , RedisArgs.GetScore(max, exclusiveMax))));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 移除有序集 <paramref name="key"/> 中,权重值在 <paramref name="min"/> 和 <paramref name="max"/> 之间的成员。
        /// </summary>
        /// <param name="client">Redis 客户端。</param>
        /// <param name="key">有序集的键名。</param>
        /// <param name="min">权重最小值。<paramref name="min"/> 可以是 <see cref="Double.MinValue"/> -或- <see cref="Double.NegativeInfinity"/>,表示有序集的最小值。</param>
        /// <param name="max">权重最大值。<paramref name="max"/> 可以是 <see cref="Double.MaxValue"/> -或- <see cref="Double.PositiveInfinity"/>,表示有序集的最高值。</param>
        /// <param name="exclusiveMin">指示最小值是否为开区间(true 时表示不含最小值)。</param>
        /// <param name="exclusiveMax">指示最大值是否为开区间(true 时表示不含最大值)。</param>
        /// <returns>被移除成员的数量。</returns>
        public static long ZRemRangeByScore(this IRedisClient client, string key, double min, double max, bool exclusiveMin = false, bool exclusiveMax = false)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }
            if (string.IsNullOrWhiteSpace(key))
            {
                throw new ArgumentNullException(nameof(key));
            }

            return(client.Execute(new RedisInteger("ZREMRANGEBYSCORE", key
                                                   , RedisArgs.GetScore(min, exclusiveMin)
                                                   , RedisArgs.GetScore(max, exclusiveMax))));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 返回有序集 <paramref name="key"/> 中,权重值在 <paramref name="min"/> 和 <paramref name="max"/> 之间的成员。
        /// <para>1、其中成员的位置按权重值递减(从大到小)来排列。</para>
        /// <para>2、具有相同权重值的成员按字典序的逆序(reverse lexicographical order)排列。</para>
        /// </summary>
        /// <param name="client">Redis 客户端。</param>
        /// <param name="key">有序集的键名。</param>
        /// <param name="min">权重最小值。<paramref name="min"/> 可以是 <see cref="System.Double.MinValue"/> -或- <see cref="System.Double.NegativeInfinity"/>,表示有序集的最小值。</param>
        /// <param name="max">权重最大值。<paramref name="max"/> 可以是 <see cref="System.Double.MaxValue"/> -或- <see cref="System.Double.PositiveInfinity"/>,表示有序集的最高值。</param>
        /// <param name="exclusiveMin">指示最小值是否为开区间(true 时表示不含最小值)。</param>
        /// <param name="exclusiveMax">指示最大值是否为开区间(true 时表示不含最大值)。</param>
        /// <param name="offset">返回结果的偏移量。</param>
        /// <param name="count">返回结果的数量。</param>
        /// <returns>返回权重值包含指定区间的成员。</returns>
        public static BinaryValue[] ZRevRangeByScore(this IRedisClient client, string key, double min, double max
                                                     , bool exclusiveMin = false, bool exclusiveMax = false
                                                     , long?offset       = null, long?count = null)
        {
            if (client == null)
            {
                throw new ArgumentNullException("client");
            }
            if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentNullException("key");
            }
            IEnumerable <object> args = new object[] { key, RedisArgs.GetScore(min, exclusiveMin), RedisArgs.GetScore(max, exclusiveMax) };

            if (offset.HasValue && count.HasValue)
            {
                args = RedisArgs.ConcatAll(args, new[] { "LIMIT", offset.Value.ToString(), count.Value.ToString() });
            }
            return(client.Execute(RedisArray.Create(new RedisValue("ZREVRANGEBYSCORE", args.ToArray()))));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 返回有序集 <paramref name="key"/> 中,权重值在 <paramref name="min"/> 和 <paramref name="max"/> 之间的成员(含成员的权重值)。
        /// <para>1、其中成员的位置按权重值递减(从大到小)来排列。</para>
        /// <para>2、具有相同权重值的成员按字典序的逆序(reverse lexicographical order)排列。</para>
        /// </summary>
        /// <param name="client">Redis 客户端。</param>
        /// <param name="key">有序集的键名。</param>
        /// <param name="min">权重最小值。<paramref name="min"/> 可以是 <see cref="Double.MinValue"/> -或- <see cref="Double.NegativeInfinity"/>,表示有序集的最小值。</param>
        /// <param name="max">权重最大值。<paramref name="max"/> 可以是 <see cref="Double.MaxValue"/> -或- <see cref="Double.PositiveInfinity"/>,表示有序集的最高值。</param>
        /// <param name="exclusiveMin">指示最小值是否为开区间(true 时表示不含最小值)。</param>
        /// <param name="exclusiveMax">指示最大值是否为开区间(true 时表示不含最大值)。</param>
        /// <param name="offset">返回结果的偏移量。</param>
        /// <param name="count">返回结果的数量。</param>
        /// <returns>权重值包含指定区间的成员(含成员的权重值)。</returns>
        public static RedisScoreItem[] ZRevRangeByScoreWithScores(this IRedisClient client, string key, double min, double max
                                                                  , bool exclusiveMin = false, bool exclusiveMax = false
                                                                  , long?offset       = null, long?count = null)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }
            if (string.IsNullOrWhiteSpace(key))
            {
                throw new ArgumentNullException(nameof(key));
            }

            IEnumerable <object> args = new object[] { key, RedisArgs.GetScore(min, exclusiveMin), RedisArgs.GetScore(max, exclusiveMax), "WITHSCORES" };

            if (offset.HasValue && count.HasValue)
            {
                args = RedisArgs.ConcatAll(args, new[] { "LIMIT", offset.Value.ToString(), count.Value.ToString() });
            }
            return(client.Execute(RedisArray.Create(new RedisItem <RedisScoreItem>(false, "ZREVRANGEBYSCORE", args.ToArray()), 2)));
        }