コード例 #1
0
        protected virtual TypedRedisValue Rpush(RedisClient client, RedisRequest request)
        {
            var  key    = request.GetKey(1);
            long length = -1;

            for (int i = 2; i < request.Count; i++)
            {
                length = Rpush(client.Database, key, request.GetValue(i));
            }
            return(TypedRedisValue.Integer(length));
        }
コード例 #2
0
        protected virtual TypedRedisValue Srem(RedisClient client, RedisRequest request)
        {
            int removed = 0;
            var key     = request.GetKey(1);

            for (int i = 2; i < request.Count; i++)
            {
                if (Srem(client.Database, key, request.GetValue(i)))
                {
                    removed++;
                }
            }
            return(TypedRedisValue.Integer(removed));
        }
コード例 #3
0
        protected virtual TypedRedisValue LRange(RedisClient client, RedisRequest request)
        {
            var  key = request.GetKey(1);
            long start = request.GetInt64(2), stop = request.GetInt64(3);

            var len = Llen(client.Database, key);

            if (len == 0)
            {
                return(TypedRedisValue.EmptyArray);
            }

            if (start < 0)
            {
                start = len + start;
            }
            if (stop < 0)
            {
                stop = len + stop;
            }

            if (stop < 0 || start >= len || stop < start)
            {
                return(TypedRedisValue.EmptyArray);
            }

            if (start < 0)
            {
                start = 0;
            }
            else if (start >= len)
            {
                start = len - 1;
            }

            if (stop < 0)
            {
                stop = 0;
            }
            else if (stop >= len)
            {
                stop = len - 1;
            }

            var arr = TypedRedisValue.Rent(checked ((int)((stop - start) + 1)), out var span);

            LRange(client.Database, key, start, span);
            return(arr);
        }
コード例 #4
0
 protected virtual TypedRedisValue Scard(RedisClient client, RedisRequest request)
 => TypedRedisValue.Integer(Scard(client.Database, request.GetKey(1)));
コード例 #5
0
 protected virtual TypedRedisValue Spop(RedisClient client, RedisRequest request)
 => TypedRedisValue.BulkString(Spop(client.Database, request.GetKey(1)));
コード例 #6
0
 protected virtual TypedRedisValue Sismember(RedisClient client, RedisRequest request)
 => Sismember(client.Database, request.GetKey(1), request.GetValue(2)) ? TypedRedisValue.One : TypedRedisValue.Zero;