From d40b88eebb260d98ad8e93cc2073e7bba49443cd Mon Sep 17 00:00:00 2001 From: nxshock Date: Fri, 2 Dec 2022 21:37:15 +0500 Subject: [PATCH] Replace Mutex with RWMutex --- zkv.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zkv.go b/zkv.go index d8b75fa..25fbb94 100644 --- a/zkv.go +++ b/zkv.go @@ -18,7 +18,7 @@ type Database struct { filePath string offset int64 - mu sync.Mutex + mu sync.RWMutex } func (db *Database) Close() error { @@ -60,8 +60,8 @@ func (db *Database) Set(key, value interface{}) error { } func (db *Database) Get(key, value interface{}) error { - db.mu.Lock() - defer db.mu.Unlock() + db.mu.RLock() + defer db.mu.RUnlock() hashToFind, err := hashInterface(key) if err != nil {