aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralex <[email protected]>2026-07-08 20:35:41 +0200
committeralex <[email protected]>2026-07-08 20:35:41 +0200
commit880d3ae49f178e61be809fb5d2c68d5f63ea700b (patch)
tree3919f0d42c7cd5f2fe82ea5399008c62db58801f
parent513e5e7961ecc9fe8155811d6cbb6a6c77e0638d (diff)
downloadredis-clone-880d3ae49f178e61be809fb5d2c68d5f63ea700b.tar.xz
redis-clone-880d3ae49f178e61be809fb5d2c68d5f63ea700b.zip
gave shards ids
-rw-r--r--handlers.go3
-rw-r--r--main.go1
-rw-r--r--shards.go1
3 files changed, 2 insertions, 3 deletions
diff --git a/handlers.go b/handlers.go
index aefea85..1a04db9 100644
--- a/handlers.go
+++ b/handlers.go
@@ -59,9 +59,6 @@ func handleExists(conn net.Conn, args []string) {
}
func handleSet(conn net.Conn, args []string) {
- db.mu.Lock()
- defer db.mu.Unlock()
-
if len(args) != 3 {
err := errors.New("wrong number of arguments for 'SET'")
conn.Write(serializeRESP(err))
diff --git a/main.go b/main.go
index 5e56280..ca8ab44 100644
--- a/main.go
+++ b/main.go
@@ -47,6 +47,7 @@ func main() {
for i := 0; i < numShards; i++ {
shards[i] = &Shard{
data: make(map[string]Item),
+ id: i,
}
}
db = RedisDB{shards: shards}
diff --git a/shards.go b/shards.go
index 55ab976..bd19751 100644
--- a/shards.go
+++ b/shards.go
@@ -6,6 +6,7 @@ import (
)
type Shard struct{
mu sync.Mutex
+ id int
data map[string]Item
}