 (def TRM-DATA-BLOCK (string :utf-8 :suffix "\r\n"))
 (def C (string :utf-8 :delimiters " "))
 (def K (string :utf-8 :delimiters " "))
+(def KV (string :utf-8 :prefix " " :suffix "\r\n"))
 (def CR (string :utf-8 :delimiters ["\r\n"]))
 
 (defcodec SET ["SET" CR])
-(defcodec STORED ["STORED" CR])
+(defcodec STORED ["STORED\r\n"])
 ;STORED\r\n
 
 (defcodec GET ["GET" CR])
 (defcodec GETS ["GETS" CR])
-(defcodec END ["END" CR])
-(defcodec VALUE [C CR CR])
+(defcodec VALUE ["VALUE" CR CR])
+(defcodec END ["END\r\n"])
 
 ; to test (decode GET-REPLY gets_test_b)
-(defcodec GET-REPLY (repeated VALUE :prefix :none :delimiters ["END\r\n"]))
+; (decode GET-REPLY (encode GET-REPLY [["VALUE" "abc" "123"] ["VALUE" "abc" "123"]])) 
+; (defcodec GET-REPLY (repeated VALUE :prefix :none :delimiters ["END\r\n"]))
 
 ;VALUE <key> <flags> <bytes> [<cas unique>]\r\n
 ;<data block>\r\n


;(def sb (java.nio.ByteBuffer/wrap (.getBytes "STORED\r\nVALUE abc\r\n123\r\n")))
;(defcodec X ["STORED" CR C CR CR "END" CR])
;(def get_test_b (java.nio.ByteBuffer/wrap (.getBytes "VALUE abc\r\n123\r\nEND\r\n")))
;(def gets_test_b (java.nio.ByteBuffer/wrap (.getBytes "VALUE abc\r\n123\r\nVALUE cde\r\n456\r\nEND\r\n")))
;(def value_test_b (java.nio.ByteBuffer/wrap (.getBytes "VALUE abc\r\n123\r\n")))
;(def values_test_b (java.nio.ByteBuffer/wrap (.getBytes "VALUE abc\r\n123\r\nVALUE cde\r\n456\r\n")))

(defcodec CMDS
          (header C
                  (fn [h]
                    (println "processing " h)
                    (case h
                      "SET" SET
                      "GET" GET
                      "GETS" GETS
                      "STORED" (do (println "do stored") STORED)
                      "VALUE" (do (println "do value") VALUE)
                      "END" END
                      (do (println "err") ERRC)))
                  first))

