Exemplo n.º 1
0
 public SET(Key key, BulkString value, Expiration expiration, Condition?condition = null)
 {
     this.key        = key;
     this.value      = value;
     this.expiration = expiration;
     this.condition  = condition;
 }
Exemplo n.º 2
0
            private static bool Equals(BulkString a, BulkString b)
            {
                if (a.IsNull && b.IsNull)
                {
                    return(true);
                }

                if (a.IsNull || b.IsNull)
                {
                    return(false);
                }

                if (a.Length != b.Length)
                {
                    return(false);
                }

                var aBytes = a.ToBytes();
                var bBytes = b.ToBytes();

                for (var i = 0; i < aBytes.Length; i++)
                {
                    if (aBytes[i] != bBytes[i])
                    {
                        return(false);
                    }
                }

                return(true);
            }
Exemplo n.º 3
0
 public override Equality Visit(BulkString bulkString) => new Equality(
     @false,
     @false,
     @false,
     @false,
     another => Equals(another, bulkString)
     );
Exemplo n.º 4
0
 public LINSERT(Key key, Where where, BulkString pivot, BulkString element)
 {
     this.key     = key;
     this.where   = where;
     this.pivot   = pivot;
     this.element = element;
 }
Exemplo n.º 5
0
            public override Response Visit(BulkString bulkString)
            {
                if (bulkString.IsNull)
                {
                    return(Response.OperationNotPerformedDueToCondition);
                }

                throw Exception(bulkString);
            }
        protected override string PackageCommand(string commandName, params string[] args)
        {
            BulkString[] cmd = new BulkString[args.Length + 1];
            cmd[0] = new BulkString(commandName);
            for (int i = 0; i < args.Length; i++)
            {
                cmd[i + 1] = new BulkString(args[i]);
            }

            return(RedisArray.Package(cmd));
        }
Exemplo n.º 7
0
        public ZINCRBY(Key key, double increment, BulkString member)
        {
            if (double.IsNaN(increment))
            {
                throw new ArgumentException("Must not be NaN", nameof(increment));
            }

            this.key       = key;
            this.increment = increment;
            this.member    = member;
        }
Exemplo n.º 8
0
        public HINCRBYFLOAT(Key key, BulkString field, double increment)
        {
            if (double.IsInfinity(increment) || double.IsNaN(increment))
            {
                throw new ArgumentException($"Must be regular number, but {increment} found", nameof(increment));
            }

            this.key       = key;
            this.field     = field;
            this.increment = increment;
        }
Exemplo n.º 9
0
 public static BulkString[] Request(BulkString name, Key key, long count, BulkStringFactory factory) =>
 count == 1
         ? new[]
 {
     name,
     key.ToBulkString(factory)
 }
         : new[]
 {
     name,
     key.ToBulkString(factory),
     factory.Create(count)
 };
Exemplo n.º 10
0
        private LexBound(Kind kind, BulkString value)
        {
            if (value is null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            if (value.IsNull)
            {
                throw new ArgumentException("Must not be null bulk string", nameof(value));
            }

            this.kind  = kind;
            this.value = value;
        }
Exemplo n.º 11
0
        public override int Visit(BulkString bulkString)
        {
            if (bulkString.IsNull)
            {
                return(-1);
            }

            var bytes = bulkString.ToBytes();

            if (bytes.Length == 0)
            {
                return(-2);
            }

            var hash = (int)bytes[0];

            for (var i = 1; i < bytes.Length; i++)
            {
                hash = (hash * 31) ^ bytes[i];
            }

            return(hash);
        }
Exemplo n.º 12
0
 public SET(Key key, BulkString value)
     : this(key, value, None.Singleton)
 {
 }
Exemplo n.º 13
0
 public override DataType Visit(BulkString bulkString) => bulkString;
Exemplo n.º 14
0
 public override double Visit(BulkString bulkString) => bulkString.ToDouble();
Exemplo n.º 15
0
 public override Array Visit(BulkString bulkString) => throw new ArgumentException("Array expected");
Exemplo n.º 16
0
 public HINCRBY(Key key, BulkString field, long increment)
 {
     this.key       = key;
     this.field     = field;
     this.increment = increment;
 }
Exemplo n.º 17
0
        public override IReadOnlyList <T> Visit(BulkString bulkString)
        {
            var list = listVisitor.Visit(bulkString);

            return(Project(list));
        }
Exemplo n.º 18
0
 public ZRANK(Key key, BulkString member)
 {
     this.key    = key;
     this.member = member;
 }
Exemplo n.º 19
0
 public override string Visit(BulkString bulkString) => bulkString.ToString();
Exemplo n.º 20
0
 public override T Visit(BulkString bulkString) => throw Exception(bulkString);
Exemplo n.º 21
0
 public override string Visit(BulkString bulkString) => indentation + "$" + Encoding.UTF8.GetString(
     bulkString.ToBytes()
     );
Exemplo n.º 22
0
 public SETEX(Key key, long seconds, BulkString value)
 {
     this.key     = key;
     this.seconds = seconds;
     this.value   = value;
 }
Exemplo n.º 23
0
 private static Key Parse(BulkString response)
 {
     return(response.IsNull
         ? null
         : new Key.BulkString(response));
 }
Exemplo n.º 24
0
 public override long?Visit(BulkString bulkString) => bulkString.IsNull
     ? default(long?)
     : throw Exception(bulkString);
Exemplo n.º 25
0
 public SISMEMBER(Key key, BulkString member)
 {
     this.key    = key;
     this.member = member;
 }
Exemplo n.º 26
0
 public override IReadOnlyList <DataType> Visit(BulkString bulkString) =>
 throw new ArgumentException("Array expected");
Exemplo n.º 27
0
 public override bool Visit(BulkString bulkString) => bulkStringEquality(bulkString);
Exemplo n.º 28
0
 public LSET(Key key, Index index, BulkString element)
 {
     this.key     = key;
     this.index   = index;
     this.element = element;
 }
Exemplo n.º 29
0
 public override long Visit(BulkString bulkString) => throw new VisitException("Integer expected", bulkString);
Exemplo n.º 30
0
 public LREM(Key key, Count count, BulkString element)
 {
     this.key     = key;
     this.count   = count;
     this.element = element;
 }