Exemple #1
0
func replyLoop(replyReader *redisio.Reader, replyWriter *redisio.Writer) {
	for {
		if reply, err := replyReader.ReadReply(); err != nil {
			fmt.Fprintf(os.Stderr, "redis read reply failed: %v\n", err)
			return
		} else {

			fmt.Printf("Reply: %v\n", reply)

			if err = replyWriter.WriteReply(reply); err != nil {
				fmt.Fprintf(os.Stderr, "redis write reply failed: %v\n", err)
				return
			}
			replyWriter.Flush()
		}
	}
}
Exemple #2
0
// proxies from client to server
func cmdLoop(cmdReader *redisio.Reader, cmdWriter *redisio.Writer) {
	for {
		if command, err := cmdReader.ReadCommand(); err != nil {
			fmt.Fprintf(os.Stderr, "redis read command failed: %v\n", err)
			return
		} else {

			fmt.Printf("Command: %v\n", command)

			if err = cmdWriter.WriteCommand(command); err != nil {
				fmt.Fprintf(os.Stderr, "redis write command failed: %v\n", err)
				return
			}
			cmdWriter.Flush()
		}
	}
}