X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=blobdiff_plain;f=extra%2Fredis%2Fcommand-writer%2Fcommand-writer.factor;h=6657f64b0a5bffab56afafe7de1874912ac44aa3;hp=af6ac6021c50fc85944f5c0260bd9c6b2cba3fb3;hb=5060e8bd5fdc18dc1bea82f06cf1b9a2699441b6;hpb=10e78dde3637ed0adca1972c76e7f283096cdcdc diff --git a/extra/redis/command-writer/command-writer.factor b/extra/redis/command-writer/command-writer.factor index af6ac6021c..6657f64b0a 100644 --- a/extra/redis/command-writer/command-writer.factor +++ b/extra/redis/command-writer/command-writer.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2009 Bruno Deferrari ! See http://factorcode.org/license.txt for BSD license. USING: arrays assocs formatting kernel math math.parser -sequences strings ; +sequences strings make ; IN: redis.command-writer string ] when ] map write-resp ; +: write-command-multi ( sequence command -- ) + prepend + [ dup number? [ number>string ] when ] map + write-resp ; + +:: (script-eval) ( script keys args command -- ) + [ script , keys length , keys % args % ] { } make + { command } + write-command-multi ; + PRIVATE> ! Connection @@ -122,3 +132,13 @@ PRIVATE> ! Remote server control : info ( -- ) { "INFO" } write-resp ; : monitor ( -- ) { "MONITOR" } write-resp ; + +! Lua +: script-load ( script -- ) 1array { "SCRIPT" "LOAD" } write-command-multi ; +: script-exists ( scripts -- ) { "SCRIPT" "EXISTS" } write-command-multi ; +: script-flush ( -- ) { } { "SCRIPT" "FLUSH" } write-command-multi ; +: script-kill ( -- ) { } { "SCRIPT" "KILL" } write-command-multi ; +! YES | SYNC | NO +: script-debug ( debug -- ) 1array { "SCRIPT" "DEBUG" } write-command-multi ; +: script-evalsha ( sha keys args -- ) "EVALSHA" (script-eval) ; +: script-eval ( script keys args -- ) "EVAL" (script-eval) ;