 
 ;get <key>*\r\n
 ;gets <key>*\r\n
-
-; this doesn't work as expected (for this protocol), because the last repeated element will also be
-; delimited. 
-(defcodec KEYS (repeated (string :utf-8 :delimiters [" "]) 
-                         :delimiters ["\r\n" " "]))
-
 (defcodec GET ["get" CR])
 (defcodec GETS ["gets" CR])
 
-(defcodec VALUE ["VALUE" K V V CR CR])
-;VALUE <key> <flags> <bytes> [<cas unique>]\r\n
-;<data block>\r\n
-;...
+;VALUE <key> <flags> <bytes> [<cas unique>]\r\n<data block>\r\n
+;VALUE <key> <flags> <bytes>\r\n<data block>\r\n
+(defcodec VALUE ["VALUE" K V CR CR])
 
+;END\r\n
 (defcodec END ["END"])
-;END\r\n
 
 (defcodec ERRC CR)
 

  (println (format "b->h '%s'" body))
  (first body))

(defn memcache-pre-encode [req]
  (println (format "memcache-pre-encode '%s'" req))
  req)

(defn memcache-post-decode [res]
  (println (format "memcache-post-decode '%s'" res))
  res)

(defcodec MEMCACHE (compile-frame 
                     (header CMD h->b b->h)

  (println (format "body->h: '%s' '%s'" body (first body)))
  (first body))

(defn h->b [hd] 
  "Called when decoding. Determines how to construct the body."
  (println (format "header h->b: '%s'" hd))
    (case hd
      "gets"   GETS
      "get"    GET
      "set"    SET
      "VALUE"  VALUE
      "STORED" STORED
      "END"    END
          ERRC))

(defn b->h 
  "Called when encoding. Determines the header that is generated."
