@@ -96,24 +96,30 @@ noted in the 'Commands' section above.
96
96
97
97
All meta commands follow a basic syntax:
98
98
99
- cm <key> <flags > <token1> <token2 > <...>\r\n
99
+ <cm> <key> <flag1 > <flag2 > <...>\r\n
100
100
101
- Where 'cm' is a 2 character command code. The number of tokens supplied is
102
- based off of the flags used.
101
+ Where <cm> is a 2 character command code.
103
102
104
103
Responses look like:
105
104
106
- RC <flags > <token1 > <token2 > <...>\r\n
105
+ <RC > <flag1 > <flag2 > <...>\r\n
107
106
108
- Where 'rc' is a 2 character return code. The number of tokens returned are
109
- based off of the flags used .
107
+ Where <RC> is a 2 character return code. The number of flags returned are
108
+ based off of the flags supplied .
110
109
111
110
Flags are single character codes, ie 'q' or 'k' or 'I', which adjust the
112
111
behavior of the command. The flags are reflected in the response. The order of
113
112
which tokens are consumed or returned depend on the order of the flags given.
114
113
For example, a metaget with flags of 'st' would return tokens for "size" and
115
114
"TTL remaining" in that order. 'ts' would return "TTL remaining" then "size".
116
115
116
+ Flags are single character codes, ie 'q' or 'k' or 'O', which adjust the
117
+ behavior of a command. Flags may contain token arguments, which come after the
118
+ flag and before the next space or newline, ie 'Oopaque' or 'Kuserkey'. Flags
119
+ can return new data or reflect information, in the same order they were
120
+ supplied in the request. Sending an 't' flag with a get for an item with 20
121
+ seconds of TTL remaining, would return 't20' in the response.
122
+
117
123
Syntax errors are handled the same as noted under 'Error strings' section
118
124
below.
119
125
@@ -456,7 +462,11 @@ me <key>\r\n
456
462
457
463
The response looks like:
458
464
459
- ME <key> <k>=<v>*\r\nEN\r\n
465
+ ME <key> <k>=<v>*\r\n
466
+
467
+ A miss looks like:
468
+
469
+ EN\r\n
460
470
461
471
Each of the keys and values are the internal data for the item.
462
472
@@ -476,22 +486,15 @@ The meta get command is the generic command for retrieving key data from
476
486
memcached. Based on the flags supplied, it can replace all of the commands:
477
487
"get", "gets", "gat", "gats", "touch", as well as adding new options.
478
488
479
- mg <key> <flags> <tokens> *\r\n
489
+ mg <key> <flags>*\r\n
480
490
481
491
- <key> means one key string. Unlike "get" metaget can only take a single key.
482
492
483
493
- <flags> are a set of single character codes ended with a space or newline.
484
-
485
- - <tokens>* means zero or more tokens, based on the flags supplied. They are
486
- consumed in order specified by the flags.
494
+ flags may have strings after the initial character.
487
495
488
496
After this command, the client expects an item to be returned, received as a
489
- text line followed by an optional data block. After the item is transferred,
490
- the server sends the string
491
-
492
- "EN\r\n"
493
-
494
- to indicate the end of the response.
497
+ text line followed by an optional data block.
495
498
496
499
If a response line appearing in a retrieval request is not sent back
497
500
by the server this means that the server does not
@@ -501,36 +504,46 @@ deleted by a client).
501
504
502
505
An item sent by the server looks like:
503
506
504
- VA <flags > <tokens >*\r\n
507
+ VA <size > <flags >*\r\n
505
508
<data block>\r\n
506
509
507
- - <flags> are a reflection of the flags sent to the server. Extra flags can be
508
- added to the response based on the execution of the command.
510
+ - <size> is the size of <data block> in bytes, minus the \r\n
509
511
510
- - <tokens >* are tokens returned by the server, based on the flags supplied.
512
+ - <flags >* are tokens returned by the server, based on the flags supplied.
511
513
They are added in order specified by the flags sent.
512
514
513
515
- <data block> is the data for this item. Note that the data black is
514
516
optional, requiring the 'v' flag to be supplied.
515
517
518
+ If the request did not ask for a value in the response (v) flag, the server
519
+ response instead looks like:
520
+
521
+ HD <flags>*\r\n
522
+
523
+ If the request resulted in a miss, the response looks like:
524
+
525
+ EN\r\n
526
+
527
+ Unless the (q) flag was supplied, which suppresses the status code for a miss.
528
+
516
529
The flags used by the 'mg' command are:
517
530
518
531
- c: return item cas token
519
532
- f: return client flags token
520
533
- h: return whether item has been hit before as a 0 or 1
521
534
- k: return key as a token
522
535
- l: return time since item was last accessed in seconds
523
- - O (token): opaque value, consumes a token and copies back with response
536
+ - O(token): opaque value, consumes a token and copies back with response
524
537
- q: use noreply semantics for return codes.
525
538
- s: return item size token
526
539
- t: return item TTL remaining in seconds (-1 for unlimited)
527
540
- u: don't bump the item in the LRU
528
541
- v: return item value in <data block>
529
542
530
543
These flags can modify the item:
531
- - N (token): vivify on miss, takes TTL as a argument
532
- - R (token): if token is less than remaining TTL win for recache
533
- - T (token): update remaining TTL
544
+ - N(token): vivify on miss, takes TTL as a argument
545
+ - R(token): if token is less than remaining TTL win for recache
546
+ - T(token): update remaining TTL
534
547
535
548
These extra flags can be added to the response:
536
549
- W: client has "won" the recache flag
@@ -546,9 +559,9 @@ The above two flags return the value of "hit before?" and "last access time"
546
559
before the command was processed. Otherwise this would always show a 1 for
547
560
hit or always show an access time of "0" unless combined with the "u" flag.
548
561
549
- - O (token): opaque value, consumes a token and copies back with response
562
+ - O(token): opaque value, consumes a token and copies back with response
550
563
551
- The O (opaque) token is used by this and other commands to allow easier
564
+ The O(opaque) token is used by this and other commands to allow easier
552
565
pipelining of requests while saving bytes on the wire for responses. For
553
566
example: if pipelining three get commands together, you may not know which
554
567
response belongs to which without also retrieving the key. If the key is very
@@ -581,10 +594,10 @@ access time.
581
594
- v: return item value in <data block>
582
595
583
596
The data block for a metaget response is optional, requiring this flag to be
584
- passed in.
597
+ passed in. The response code also changes from "HD" to "VA <size>"
585
598
586
599
These flags can modify the item:
587
- - N (token): vivify on miss, takes TTL as a argument
600
+ - N(token): vivify on miss, takes TTL as a argument
588
601
589
602
Used to help with so called "dog piling" problems with recaching of popular
590
603
items. If supplied, and metaget does not find the item in cache, it will
@@ -599,14 +612,14 @@ already received the win flag.
599
612
600
613
Can be combined with CAS flags to gate the update further.
601
614
602
- - R (token): if token is less than remaining TTL win for recache
615
+ - R(token): if token is less than remaining TTL win for recache
603
616
604
617
Similar to and can be combined with 'N'. If the remaining TTL of an item is
605
618
below the supplied token, return a 'W' flag to indicate the client has "won"
606
619
the right to recache an item. This allows refreshing an item before it leads to
607
620
a miss.
608
621
609
- - T (token): update remaining TTL
622
+ - T(token): update remaining TTL
610
623
611
624
Similar to "touch" and "gat" commands, updates the remaining TTL of an item if
612
625
hit.
@@ -646,27 +659,25 @@ The meta set command a generic command for storing data to memcached. Based on
646
659
the flags supplied, it can replace the commands: "set", "cas". as well as
647
660
adding new options.
648
661
649
- ms <key> <flags> <tokens> *\r\n
662
+ ms <key> <flags>*\r\n
650
663
651
664
- <key> means one key string.
652
665
653
666
- <flags> are a set of single character codes ended with a space or newline.
654
-
655
- - <tokens>* means zero or more tokens, based on the flags supplied. They are
656
- consumed in order specified by the flags.
667
+ flags may have strings after the initial character.
657
668
658
669
After this line, the client sends the data block:
659
670
660
671
<data block>\r\n
661
672
662
673
- <data block> is a chunk of arbitrary 8-bit data of length supplied by an 'S'
663
- flag and token from the previous line. If no 'S' flag is supplied the data
674
+ flag and token from the request line. If no 'S' flag is supplied the data
664
675
is assumed to be 0 length.
665
676
666
677
After sending the command line and the data block the client awaits
667
678
the reply, which is of the format:
668
679
669
- CD <flags> <tokens>*\r\n
680
+ <CD> <flags> <tokens>*\r\n
670
681
671
682
Where CD is one of:
672
683
@@ -683,33 +694,33 @@ with CAS semantics did not exist.
683
694
684
695
The flags used by the 'ms' command are:
685
696
686
- - C (token): compare CAS value when storing item
687
- - F (token): set client flags to token (32 bit unsigned numeric)
688
- - I: invalid . set-to-invalid if CAS is older than it should be.
697
+ - C(token): compare CAS value when storing item
698
+ - F(token): set client flags to token (32 bit unsigned numeric)
699
+ - I: invalidate . set-to-invalid if supplied CAS is older than item's CAS
689
700
- k: return key as a token
690
- - O (token): opaque value, consumes a token and copies back with response
701
+ - O(token): opaque value, consumes a token and copies back with response
691
702
- q: use noreply semantics for return codes
692
- - S (token): size of <data block> to store
693
- - T (token): Time-To-Live for item, see "Expiration" above.
703
+ - S(token): size of <data block> to store
704
+ - T(token): Time-To-Live for item, see "Expiration" above.
694
705
695
706
The flags are now repeated with detailed information where useful:
696
707
697
- - C (token): compare CAS value when storing item
708
+ - C(token): compare CAS value when storing item
698
709
699
710
Similar to the basic "cas" command, only store item if the supplied token
700
711
matches the current CAS value of the item. When combined with the 'I' flag, a
701
712
CAS value that is _lower_ than the current value may be accepted, but the item
702
713
will be marked as "stale", returning the X flag with mget requests.
703
714
704
- - F (token): set client flags to token (32 bit unsigned numeric)
715
+ - F(token): set client flags to token (32 bit unsigned numeric)
705
716
706
717
Sets flags to 0 if not supplied.
707
718
708
719
- I: invalid. set-to-invalid if CAS is older than it should be.
709
720
710
721
Functional when combined with 'C' flag above.
711
722
712
- - O (token): opaque value, consumes a token and copies back with response
723
+ - O(token): opaque value, consumes a token and copies back with response
713
724
714
725
See description under 'Meta Get'
715
726
@@ -728,18 +739,16 @@ Meta Delete
728
739
The meta delete command allows for explicit deletion of items, as well as
729
740
marking items as "stale" to allow serving items as stale during revalidation.
730
741
731
- md <key> <flags> <tokens> *\r\n
742
+ md <key> <flags>*\r\n
732
743
733
744
- <key> means one key string.
734
745
735
746
- <flags> are a set of single character codes ended with a space or newline.
736
-
737
- - <tokens>* means zero or more tokens, based on the flags supplied. They are
738
- consumed in order specified by the flags.
747
+ flags may have strings after the initial character.
739
748
740
749
The response is in the format:
741
750
742
- CD <flags> <tokens>*\r\n
751
+ <CD> <flags> <tokens>*\r\n
743
752
744
753
Where CD is one of:
745
754
@@ -752,16 +761,16 @@ Where CD is one of:
752
761
753
762
The flags used by the 'md' command are:
754
763
755
- - C (token): compare CAS value
764
+ - C(token): compare CAS value
756
765
- I: invalidate. mark as stale, bumps CAS.
757
766
- k: return key
758
- - O: opaque to copy back.
767
+ - O(token) : opaque to copy back.
759
768
- q: noreply
760
- - T (token): updates TTL, only when paired with the 'I' flag
769
+ - T(token): updates TTL, only when paired with the 'I' flag
761
770
762
771
The flags are now repeated with detailed information where useful:
763
772
764
- - C (token): compare CAS value
773
+ - C(token): compare CAS value
765
774
766
775
Can be used to only delete or mark-stale if a supplied CAS value matches.
767
776
@@ -771,7 +780,7 @@ Instead of removing an item, this will give the item a new CAS value and mark
771
780
it as stale. This means when it is later fetched by metaget, the client will
772
781
be supplied an 'X' flag to show the data is stale and needs to be recached.
773
782
774
- - O (token): opaque to copy back.
783
+ - O(token): opaque to copy back.
775
784
776
785
See description under 'Meta Get'
777
786
@@ -780,7 +789,7 @@ See description under 'Meta Get'
780
789
See description under 'Meta Set'. In the case of meta delete, this will hide
781
790
response lines with the code "DE". It will still return any other responses.
782
791
783
- - T (token): updates TTL, only when paired with the 'I' flag
792
+ - T(token): updates TTL, only when paired with the 'I' flag
784
793
785
794
When marking an item as stale with 'I', the 'T' flag can be used to update the
786
795
TTL as well; limiting the amount of time an item will live while stale and
@@ -794,16 +803,14 @@ takes no flags, no arguments.
794
803
795
804
This returns the static response:
796
805
797
- "EN\r\n"
798
-
799
- Similar to a meta get command.
806
+ "MN\r\n"
800
807
801
808
This command is useful when used with the 'q' flag and pipelining commands.
802
- For example, with 'mg' the response lines are blank on miss, and the 'q' flag
803
- will hide the "EN\r\n" response code . If pipelining several 'mg's together
804
- with noreply semantics, an "mn\r\n" command can be tagged to the end of the
805
- chain, which will return an "EN \r\n", signalling to a client that all previous
806
- commands have been processed.
809
+ For example, with 'mg' the response lines are blank on miss when the 'q' flag
810
+ is supplied . If pipelining several 'mg's together with noreply semantics, an
811
+ "mn\r\n" command can be tagged to the end of the chain, which will return an
812
+ "MN \r\n", signalling to a client that all previous commands have been
813
+ processed.
807
814
808
815
Slabs Reassign
809
816
--------------
0 commit comments