From 730a465d73bf47e86352d6fc0af2df9dd9db8341 Mon Sep 17 00:00:00 2001 From: tidwall Date: Tue, 30 Mar 2021 07:41:08 -0700 Subject: [PATCH] Cleanup test file --- redcon.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/redcon.go b/redcon.go index 63d497f..46b7d65 100644 --- a/redcon.go +++ b/redcon.go @@ -924,6 +924,22 @@ func (rd *Reader) readCommands(leftover *int) ([]Command, error) { return rd.readCommands(leftover) } +// ReadCommands reads the next pipeline commands. +func (rd *Reader) ReadCommands() ([]Command, error) { + for { + if len(rd.cmds) > 0 { + cmds := rd.cmds + rd.cmds = nil + return cmds, nil + } + cmds, err := rd.readCommands(nil) + if err != nil { + return []Command{}, err + } + rd.cmds = cmds + } +} + // ReadCommand reads the next command. func (rd *Reader) ReadCommand() (Command, error) { if len(rd.cmds) > 0 {