Esempio n. 1
0
        public RedisScanStrings SScanString(RedisParam key, ulong cursor = 0uL, int count = 10, RedisParam?match = null)
        {
            if (key.IsNull)
            {
                throw new ArgumentNullException("key");
            }

            ValidateNotDisposed();

            var parameters = new RedisParam[] { key, cursor.ToBytes() };

            if (match.HasValue)
            {
                var value = match.Value;
                if (!value.IsEmpty)
                {
                    parameters = parameters.Join(RedisCommandList.Match);
                    parameters = parameters.Join(value);
                }
            }

            if (count > 0)
            {
                parameters = parameters.Join(RedisCommandList.Count);
                parameters = parameters.Join(count.ToBytes());
            }

            return(RedisCommandUtils.ToScanStrings(ExpectArray(new RedisCommand(DbIndex, RedisCommandList.SScan, parameters))));
        }
Esempio n. 2
0
        public RedisResult <RedisGeoRadiusResult[]> GeoRadius(RedisParam key, RedisGeoPosition position, double radius,
                                                              RedisGeoDistanceUnit unit, bool withCoord = false, bool withDist = false, bool withHash   = false,
                                                              int count = -1, RedisSortDirection sort = RedisSortDirection.Default, RedisParam?storeKey = null,
                                                              RedisParam?storeDistanceKey = null)
        {
            if (key.IsEmpty)
            {
                throw new ArgumentNullException("key");
            }

            var parameters = key
                             .Join(position.Longitude.ToBytes())
                             .Join(position.Latitude.ToBytes())
                             .Join(radius.ToBytes())
                             .Join(ToBytes(unit));

            if (withCoord)
            {
                parameters = parameters.Join(RedisCommandList.WithCoord);
            }

            if (withDist)
            {
                parameters = parameters.Join(RedisCommandList.WithDist);
            }

            if (withHash)
            {
                parameters = parameters.Join(RedisCommandList.WithHash);
            }

            if (count > -1)
            {
                parameters = parameters.Join(RedisCommandList.Count).Join(count.ToBytes());
            }

            if (sort == RedisSortDirection.Ascending)
            {
                parameters = parameters.Join(RedisCommandList.Ascending);
            }
            else if (sort == RedisSortDirection.Descending)
            {
                parameters = parameters.Join(RedisCommandList.Descending);
            }

            if (storeKey.HasValue && !storeKey.Value.IsEmpty)
            {
                parameters = parameters.Join(RedisCommandList.Store).Join(storeKey.ToBytes());
            }

            if (storeDistanceKey.HasValue && !storeDistanceKey.Value.IsEmpty)
            {
                parameters = parameters.Join(RedisCommandList.StoreDist).Join(storeDistanceKey.ToBytes());
            }

            return(RedisCommandUtils.ToGeoRadiusArray(ExpectArray(new RedisCommand(DbIndex, RedisCommandList.GeoRadius, parameters))));
        }
Esempio n. 3
0
        public RedisResult <RedisGeoPosition[]> GeoPosition(RedisParam key, RedisParam member, params RedisParam[] members)
        {
            if (key.IsEmpty)
            {
                throw new ArgumentNullException("key");
            }

            if (member.IsEmpty)
            {
                throw new ArgumentNullException("member");
            }

            var parameters = key.Join(member);

            foreach (var m in members)
            {
                if (!m.IsEmpty)
                {
                    parameters = parameters.Join(m);
                }
            }

            return(RedisCommandUtils.ToGeoPosition(ExpectArray(new RedisCommand(DbIndex, RedisCommandList.GeoPos, parameters))));
        }
        public RedisScanBytes Scan(ulong cursor = 0uL, int count = 10, RedisParam?match = null)
        {
            ValidateNotDisposed();

            var parameters = new RedisParam[] { cursor.ToBytes() };

            if (match.HasValue)
            {
                var value = match.Value;
                if (!value.IsEmpty)
                {
                    parameters = parameters.Join(RedisCommandList.Match);
                    parameters = parameters.Join(value);
                }
            }

            if (count > 0)
            {
                parameters = parameters.Join(RedisCommandList.Count);
                parameters = parameters.Join(count.ToBytes());
            }

            return(RedisCommandUtils.ToScanBytes(ExpectArray(new RedisCommand(DbIndex, RedisCommandList.Scan, parameters))));
        }