Ejemplo n.º 1
0
        /// <summary>递减,原子操作</summary>
        /// <param name="key">键</param>
        /// <param name="value">变化量</param>
        /// <returns></returns>
        public override Int64 Decrement(String key, Int64 value)
        {
            var ms = Pool.MemoryStream.Get();

            ms.WriteArray(key.GetBytes());
            ms.Write(value.GetBytes());

            var rs = Invoke <Packet>(nameof(Decrement), ms.Put(true));

            if (rs == null || rs.Total == 0)
            {
                return(0);
            }

            return(rs.ReadBytes(0, 8).ToLong());
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Writes int64 data into internal buffer.
 /// </summary>
 /// <param name="data">int64 data to write.</param>
 protected void Write(Int64 data)
 {
     this.Write(data.GetBytes());
 }
Ejemplo n.º 3
0
 public static IEnumerable <byte> Concat(this IEnumerable <byte> sequence, Int64 value)
 {
     return(sequence.Concat(value.GetBytes()));
 }
Ejemplo n.º 4
0
 public BinaryWriter Write(Int64 value)
 {
     byteList.AddRange(value.GetBytes());
     return(this);
 }