diff options
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -126,6 +126,12 @@ func handleDecr(conn net.Conn, key string){ func handlePing(conn net.Conn) { conn.Write([]byte("+PONG\r\n")) } +func handleFlushall(conn net.Conn){ + db.mu.Lock() + db.data = make(map[string]string) + conn.Write([]byte("+OK\r\n")) + db.mu.Unlock() +} func parseRESP(reader *bufio.Reader) ([]string, error) { line, err := reader.ReadString('\n') @@ -196,6 +202,8 @@ func handleConnection(conn net.Conn) { handleDecr(conn, args[1]) case command == "PING" && len(args) == 1: handlePing(conn) + case command == "FLUSHALL" && len(args) == 1: + handleFlushall(conn) default: conn.Write([]byte("-ERR unknown command or wrong arguments\r\n")) } |
