示例#1
0
            internal static IncrementOperation Parse(BlittableJsonReaderObject input)
            {
                if (input.TryGet(nameof(Timestamp), out DateTime ts) == false)
                {
                    throw new InvalidDataException($"Missing '{nameof(Timestamp)}' property");
                }

                if (input.TryGet(nameof(Values), out BlittableJsonReaderArray values) == false || values == null)
                {
                    throw new InvalidDataException($"Missing '{nameof(Values)}' property");
                }

                var doubleValues = new double[values.Length];

                for (int i = 0; i < doubleValues.Length; i++)
                {
                    doubleValues[i] = values.GetByIndex <double>(i);
                }

                var op = new IncrementOperation
                {
                    Timestamp = ts,
                    Values    = doubleValues
                };

                return(op);
            }
示例#2
0
        /// <summary>
        /// Increments the value of the specified key by the given amount. The operation is atomic and happens on the server.
        /// </summary>
        /// <param name="key">The identifier for the item to increment.</param>
        /// <param name="amount">The amount by which the client wants to increase the item.</param>
        /// <returns>The new value of the item or -1 if not found.</returns>
        /// <remarks>The item must be inserted into the cache before it can be changed. The item must be inserted as a <see cref="T:System.String"/>. The operation only works with <see cref="System.UInt32"/> values, so -1 always indicates that the item was not found.</remarks>
        public long Increment(string key, uint amount)
        {
            using (IncrementOperation i = new IncrementOperation(this.pool, key, amount))
            {
                i.Execute();

                return(i.Success ? (long)i.Result : -1);
            }
        }
示例#3
0
 public void VisitIncrementOperation(IncrementOperation incrementOperation)
 {
     VisitExpression(incrementOperation.Expression);
 }