GetCommandBuffer() 공개 정적인 메소드

Gets the bytes representing the specified command. returned buffer can be used to streamline multiple writes into one Write on the Socket using the M:Enyim.Caching.Memcached.PooledSocket.Write(IList<ArraySegment<byte>>)
The Nagle algorithm is disabled on the socket to speed things up, so it's recommended to convert a command into a buffer and use the M:Enyim.Caching.Memcached.PooledSocket.Write(IList<ArraySegment<byte>>) to send the command and the additional buffers in one transaction.
public static GetCommandBuffer ( string value ) : IList>
value string The command to be converted.
리턴 IList>
예제 #1
0
        protected internal override IList <ArraySegment <byte> > GetBuffer()
        {
            // gets key1 key2 key3 ... keyN\r\n

            var command = "gets " + String.Join(" ", Keys.ToArray()) + TextSocketHelper.CommandTerminator;

            return(TextSocketHelper.GetCommandBuffer(command));
        }
        protected internal override IList <ArraySegment <byte> > GetBuffer()
        {
            var command = String.IsNullOrEmpty(this.type)
                                                        ? "stats" + TextSocketHelper.CommandTerminator
                                                        : "stats " + this.type + TextSocketHelper.CommandTerminator;

            return(TextSocketHelper.GetCommandBuffer(command));
        }
        protected internal override IList <ArraySegment <byte> > GetBuffer()
        {
            var command = (this.mode == MutationMode.Increment ? "incr " : "decr ")
                          + this.Key
                          + " "
                          + this.delta.ToString(CultureInfo.InvariantCulture)
                          + TextSocketHelper.CommandTerminator;

            return(TextSocketHelper.GetCommandBuffer(command));
        }
        protected internal override System.Collections.Generic.IList <ArraySegment <byte> > GetBuffer()
        {
            // todo adjust the size to fit a request using a fnv hashed key
            var sb      = new StringBuilder(128);
            var buffers = new List <ArraySegment <byte> >(3);

            switch (this.command)
            {
            case StoreCommand.Add: sb.Append("add "); break;

            case StoreCommand.Replace: sb.Append("replace "); break;

            case StoreCommand.Set: sb.Append("set "); break;

            case StoreCommand.Append: sb.Append("append "); break;

            case StoreCommand.Prepend: sb.Append("prepend "); break;

            case StoreCommand.CheckAndSet: sb.Append("cas "); break;

            default: throw new MemcachedClientException(command + " is not supported.");
            }

            sb.Append(this.Key);
            sb.Append(" ");
            sb.Append(this.value.Flags.ToString(CultureInfo.InvariantCulture));
            sb.Append(" ");
            sb.Append(this.expires.ToString(CultureInfo.InvariantCulture));
            sb.Append(" ");

            var data = this.value.Data;

            sb.Append(Convert.ToString(data.Count, CultureInfo.InvariantCulture));

            if (command == StoreCommand.CheckAndSet)
            {
                sb.Append(" ");
                sb.Append(Convert.ToString(this.cas, CultureInfo.InvariantCulture));
            }

            sb.Append(TextSocketHelper.CommandTerminator);

            TextSocketHelper.GetCommandBuffer(sb.ToString(), buffers);
            buffers.Add(data);
            buffers.Add(StoreOperationBase.DataTerminator);

            return(buffers);
        }
        protected internal override System.Collections.Generic.IList <ArraySegment <byte> > GetBuffer()
        {
            var command = "delete " + this.Key + TextSocketHelper.CommandTerminator;

            return(TextSocketHelper.GetCommandBuffer(command));
        }
예제 #6
0
 protected internal override IList <System.ArraySegment <byte> > GetBuffer()
 => TextSocketHelper.GetCommandBuffer("flush_all" + TextSocketHelper.CommandTerminator);
예제 #7
0
        protected internal override IList <ArraySegment <byte> > GetBuffer()
        {
            var command = "gets " + this.Key + TextSocketHelper.CommandTerminator;

            return(TextSocketHelper.GetCommandBuffer(command));
        }