Nikhil Marathe  committed 452912f

Added macro to create inline command functions and send them

  • Participants
  • Parent commits ba3277a

Comments (0)

Files changed (1)

 (context 'redis)
-(define (split str)
-  (parse str redis:CRLF))
+(constant 'CRLF "\r\n")
+(constant 'BUFSIZE 4096)
+(constant 'inline-commands 
+  '("ping" "bgsave" "get" "quit" "auth" "exists" "type" "select" "dbsize"))
+(define (make-inline-command command)
+  (letex ((fname (sym command)) (cmd command))
+        (define (fname r)
+          (letn ( (args-as-strings (map (fn (x) (string x)) (args)))
+                  (command-string (join (cons (upper-case cmd) args-as-strings) " ")) )
+              (:query r (append command-string redis:CRLF))))))
 (context MAIN)
       (list redis sock ""))))
-(define redis:CRLF "\r\n")
-(define redis:BUFSIZE 4096)
 (define (redis:query r command-str)
   (net-send (r 1) (append command-str redis:CRLF))
   (net-receive (r 1) buf redis:BUFSIZE)