aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/main.go b/main.go
index 3130b26..7e8c13e 100644
--- a/main.go
+++ b/main.go
@@ -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"))
}